我已经在片段兼容性包示例之后创建了一个片段选项卡小部件,我在onTabChanged
中更改了片段,但我有一些市场报告在IllegalStateException
之后发现了onSaveInstanceState
,这是由在调用onSaveInstanceState()
后要求提交片段管理器,但是如何在调用onSaveInstanceState
后收到performClick?
堆栈跟踪:
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)
看起来这是以某种方式讨论(通过搜索错误),但对我来说这只是一个副作用,一个支持的错误?我还阅读了有关honey +的不同应用程序生命周期,但在保存实例看起来无法解决的行为后执行单击
我应该在commitAllowingStateLoss()
中使用mTabHost.setOnClickListener(null)
还是onSaveInstanceState
?
不幸的是我无法重现,我只看到关于开发者控制台的罕见报告
活动有android:configChanges="orientation|screenLayout"
我也用“总是完成”来测试生命周期
标签片段切换器在ViewPager中,但我怀疑是否相关