Can not perform this action after onSaveInstanceState
来源:互联网 发布:数据存储的方式 编辑:程序博客网 时间:2024/05/18 01:42
通过Monkey测试报如下错误:
/ java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState// at android.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1411)// at android.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1429)// at android.app.BackStackRecord.commitInternal(BackStackRecord.java:687)// at android.app.BackStackRecord.commit(BackStackRecord.java:663)// at com.qualcomm.qti.setupwizard.SetupPageActivity.initSimSettingFragment(SetupPageActivity.java:360)// at com.qualcomm.qti.setupwizard.SetupPageActivity.skipView(SetupPageActivity.java:315)// at com.qualcomm.qti.setupwizard.SetupPageActivity$5.run(SetupPageActivity.java:258)// at android.os.Handler.handleCallback(Handler.java:739)// at android.os.Handler.dispatchMessage(Handler.java:95)// at android.os.Looper.loop(Looper.java:148)// at android.app.ActivityThread.main(ActivityThread.java:5417)// at java.lang.reflect.Method.invoke(Native Method)// at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)// at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
通过log可知,错误是因为在onSaveInstanceState() 方法执行之后又做了Transaction的commit操作。我个人的解决方法是执行完onSaveInstanceState() 方法后就不再执行commit操作。在onSaveInstanceState()方法中加一boolean值,在commit之前判断。代码如下:
private boolean mIsSaved = false;@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); mIsSaved = true; }public void initSimSettingFragment() { if (mIsSaved) return; mSimSettingFragment = new SimSettingFragment(); mFragmentManager.beginTransaction() .replace(R.id.base_sim, mSimSettingFragment) .commit(); }
如果想深入了解可以查看参考文章
参考文章:
http://www.cnblogs.com/kissazi2/p/4181093.html
1 0
- Can not perform this action after onSaveInstanceState
- Can not perform this action after onSaveInstanceState
- Can not perform this action after onSaveInstanceState
- Can not perform this action after onSaveInstanceState
- Can not perform this action after onSaveInstanceState
- Can not perform this action after onSaveInstanceState
- Can not perform this action after onSaveInstanceState
- Can not perform this action after onSaveInstanceState
- Can not perform this action after onSaveInstanceState
- Can not perform this action after onSaveInstanceState
- 解决IllegalStateException: Can not perform this action after onSaveInstanceState
- 解决IllegalStateException: Can not perform this action after onSaveInstanceState
- 解决IllegalStateException: Can not perform this action after onSaveInstanceState
- llegalStateException: Can not perform this action after onSaveInstanceState:
- 解决IllegalStateException: Can not perform this action after onSaveInstanceState
- IllegalStateException: Can not perform this action after onSaveInstanceState
- 解决IllegalStateException: Can not perform this action after onSaveInstanceState
- Android 异常 IllegalStateException: Can not perform this action after onSaveInstanceState
- Nutz logoJava应用框架 Nutz
- JSP里ContentType ,charset和pageEncoding的理解与区别
- 最长回文字符串
- 递归方式查找文件夹的所有文件
- 快10点了,天黑了,我睡了。。。
- Can not perform this action after onSaveInstanceState
- C++ 类的静态成员详细讲解
- lintcode coins-in-a-line-ii 硬币排成线ii
- string 分割字符串
- pclint之检查多个代码文件和库头文件
- HDU5752 Sqrt Bo
- [Cloud Computing]Mechanisms: Threat Intelligence System
- PC LINT 错误信息禁止选项说明
- perl script.pl vs perldoc script.pl