我的应用程序在某些用户设备上不断崩溃,在 Activity onStart 方法中出现以下异常:
Caused by: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1299)
at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1310)
at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:541)
at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:525)
at android.support.v4.app.DialogFragment.show(DialogFragment.java:123)
我无法在我的模拟器中本地重现此错误。我在stackoverflow上发现了一些关于这个问题的问题: here和 here
我已经尝试了建议的解决方案,即在 onSaveInstance 中不允许在 fragment 或 Activity 中使用空包。
但是问题仍然存在。这是我收到的唯一一份崩溃报告,而且我不断收到它。
有人有可行的解决方案吗?
最佳答案
我已经解决了这个问题
- 将我的支持库升级到修订版 10
- 使用此处发布的解决方法:http://code.google.com/p/android/issues/detail?id=23096 即在 onResumeFragments 中添加一个非 ui fragment 并在 Listener Callback 中调用进一步的事务。
在此处查看我的答案以获取代码:"Can not perform this action after onSaveInstanceState" - why am I getting this exception from my activity's onResume method?
到目前为止没有更多的 IllegalStateException。
关于android - IllegalStateException - fragment 支持库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11900785/