I've created a fragment tab widget following fragment compatibility package sample, I change fragment in onTabChanged
but I have some market reports that spots IllegalStateException
after onSaveInstanceState
, this is caused by asking a commit to fragment manager after calling onSaveInstanceState()
, but how can I receive a performClick after onSaveInstanceState
is called?
the stack trace:
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1314)
at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1325)
at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:548)
at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:532)
at my.app.NewsTab.onTabChanged(NewsTab.java:144)
at android.widget.TabHost.invokeOnTabChangeListener(TabHost.java:378)
at android.widget.TabHost.setCurrentTab(TabHost.java:363)
at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:149)
at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:559)
at android.view.View.performClick(View.java:3122)
at android.view.View$PerformClick.run(View.java:12012)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:132)
at android.app.ActivityThread.main(ActivityThread.java:4126)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:491)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
at dalvik.system.NativeStart.main(Native Method)
looks like this was somehow discussed (by searching the error), but for me it's only a side effect, a bug in support? I've also read about a different application lifecycle for honeycomb+, but perform click after saving instance looks unrealable behavior to me
should I use commitAllowingStateLoss()
or mTabHost.setOnClickListener(null)
in onSaveInstanceState
?
unfortunately I'm unable to reproduce, I only see rare reports on developer console
the activity has android:configChanges="orientation|screenLayout"
I've tested the lifecycle also with "always finish"
the tab fragment switcher is inside a ViewPager but I doubt can be related