Nested Preference Screen closes on Screenorientation change in Android -
i stumbled upon problem.
i working nested preferencescreen this:
<preferencescreen xmlns:android="http://schemas.android.com/apk/res/android" > <preferencescreen android:key="pref_name" android:title="@string/pref_title" > </preferencescreen>
when screen has focus on nested preference screen , change screenorientation, nested preferencescreen closes.
i have tried including:
android:configchanges="orientation|keyboardhidden"
in androidmanifest.xml, didn't work.
does have solution this?
edit possible solution:
i did find solution. thought line:
android:configchanges="keyboardhidden|orientation|screensize"
got it. in order prevent nested screen closing on rotation, need make sure parent screen given key value. thats it. eg:
<preferencescreen xmlns:android="http://schemas.android.com/apk/res/android" android:key="useless_key"> <preferencescreen android:key="pref_name" android:title="@string/pref_title" > </preferencescreen> </preferencescreen>
side note, though overriding onconfigchanges solved issue, should never so. changes how activity behaves. rotation 1 of many reasons why config change happens. if activity can't handle rotation properly, it'll fail on handling other conditions. check out insightful post more.
Comments
Post a Comment