片段IllegalStateException

时间:2016-01-21 11:24:19

标签: android android-fragments illegalstateexception

我在我的应用中遇到此异常一次,现在我不明白这是什么,也无法重新创建它。

任何人都可以帮助我。提前致谢

Fatal Exception: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
   at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1489)
   at android.support.v4.app.FragmentManagerImpl.popBackStackImmediate(FragmentManager.java:584)
   at android.support.v4.app.FragmentActivity.onBackPressed(FragmentActivity.java:169)
   at com.explorelife.UI.PropertyDetailsScreen.onBackPressed(PropertyDetailsScreen.java:310)
   at com.explorelife.UI.PropertyDetailsScreen.onClick(PropertyDetailsScreen.java:716)
   at android.view.View.performClick(View.java:4785)
   at android.view.View$PerformClick.run(View.java:19884)
   at android.os.Handler.handleCallback(Handler.java:739)
   at android.os.Handler.dispatchMessage(Handler.java:95)
   at android.os.Looper.loop(Looper.java:135)
   at android.app.ActivityThread.main(ActivityThread.java:5343)
   at java.lang.reflect.Method.invoke(Method.java)
   at java.lang.reflect.Method.invoke(Method.java:372)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)

3 个答案:

答案 0 :(得分:0)

View.performClickonSaveInstanceState之后处理。您似乎在点击时完成了您的活动。如果您在View上快速点击两次,我们就可以重现崩溃。

答案 1 :(得分:0)

您似乎试图在fragmentTransactionReplace FragmentRemove Fragment之一中提交onCreate()onResumeonStart导致Activity

illlegaStateException方法

答案 2 :(得分:0)

当在onSaveInstanceState()之后调用onBackPressed()时会发生这种情况,即当移动设备被锁定然后在后台调用onBackPressed()时,一个hack覆盖onSaveInstance()并在该方法中添加onBackPressed()并且它工作正常对我好。