I have a fragment with a TextWatcher on an edittext and the onTextChanged sends the current edittext string to a method in a DatabaseHelper class (extends SQLiteOpenHelper) to check it. If I change the orientation (I do it twice to return to normal position), the app crashes when passing the string to this method.
I tried testing whether the savedInstanceState is null (in various positions in both fragment and fragmentActivity) but the result was that there’s no TextWatcher after the orientation change.
I tried doing the addTextChangedListener in onPostCreate in the fragmentActivity (as suggested here) but that didn’t help.
Also tried
android:configChanges=”keyboardHidden|orientation|screenLayout”
but that didn’t help.
The crash comes at myDbHelper.findCurrencyCode.
The solution was found in stackoverflow and was to use android:configChanges=”orientation|screenSize” in manifest, ie.
<activity android:name="couk.jit.ratemate.AddCurrencyActivity" android:label="@string/title_activity_add_currency" android:configChanges="orientation|screenSize" > </activity>