简体   繁体   English

onWaveInstanceState之后的TabWidget onClick(java.lang.IllegalStateException:在onSaveInstanceState之后无法执行此操作)

[英]TabWidget onClick after onSaveInstanceState (java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState)

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? 我在片段兼容性包示例之后创建了一个片段选项卡小部件,我在onTabChanged更改了片段但是我有一些市场报告在onSaveInstanceState之后发现了IllegalStateException ,这是因为在调用onSaveInstanceState()之后要求提交片段管理器,但怎么能在调用onSaveInstanceState后我收到了performClick?

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 ? 我应该在onSaveInstanceState使用commitAllowingStateLoss()mTabHost.setOnClickListener(null)吗?

unfortunately I'm unable to reproduce, I only see rare reports on developer console 不幸的是我无法重现,我只看到关于开发者控制台的罕见报告

the activity has android:configChanges="orientation|screenLayout" 活动有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 标签片段切换器在ViewPager中,但我怀疑是否相关

它似乎是Android从版本4.4到版本5的错误。有关更多详细信息,请参阅此答案

The problem is that you are attempting to commit a FragmentTransaction after the Activity 's onSaveInstanceState() method has been called. 问题是您在调用ActivityonSaveInstanceState()方法后尝试提交FragmentTransaction This is not allowed for the reasons described in this blog post . 由于此博客文章中描述的原因,不允许这样做。

onSaveInstanceState() is called after the Activity is gone from the foreground. 在Activity从前台消失后调用onSaveInstanceState() You can't do anything after saving the state. 保存状态后,您无法执行任何操作。 Please, if you can, share us your code to check it. 如果可以,请分享我们的代码以进行检查。 You have to make the changes before calling onSaveInstanceState() method. 您必须在调用onSaveInstanceState()方法之前进行更改。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SupportFragment + TabWidget + Samsung Device =“java.lang.IllegalStateException:onSaveInstanceState后无法执行此操作”? - SupportFragment + TabWidget + Samsung Device = “java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState”? java.lang.IllegalStateException-在onSaveInstanceState之后无法执行此操作 - java.lang.IllegalStateException - Can not perform this action after onSaveInstanceState java.lang.IllegalStateException(在onSaveInstanceState之后无法执行此操作) - java.lang.IllegalStateException(Can not perform this action after onSaveInstanceState) java.lang.IllegalStateException:使用DialogFragment在onSaveInstanceState之后无法执行此操作 - java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState with DialogFragment 由 java.lang.IllegalStateException 引起 onSaveInstanceState 后无法执行此操作 - Caused by java.lang.IllegalStateException Can not perform this action after onSaveInstanceState java.lang.IllegalStateException:onSaveInstanceState之后无法执行此操作 - java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState java.lang.IllegalStateException:onSaveInstanceState,FragmentTabHost之后无法执行此操作 - java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState,FragmentTabHost Android java.lang.IllegalStateException:onSaveInstanceState之后无法执行此操作 - Android java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState java.lang.IllegalStateException: 在 onSaveInstanceState 之后无法执行此操作 - java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState 异常java.lang.IllegalStateException:onSaveInstanceState之后无法执行此操作 - Exception java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM