Can not perform this action after onSaveInstanceState
来源:互联网 发布:千里眼淘宝版下载 编辑:程序博客网 时间:2024/05/17 06:24
项目中出现这个东西,查了源码之后发现
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
大致意思是说我使用的 commit方法是在Activity的onSaveInstanceState()之后调用的,这样会出错,因为onSaveInstanceState
方法是在该Activity即将被销毁前调用,来保存Activity数据的,如果在保存玩状态后再给它添加Fragment就会出错。解决办法就
是把commit()方法替换成 commitAllowingStateLoss()就行了,其效果是一样的。
源码: public abstract int commitAllowingStateLoss();
* <p class="note">A transaction can only be committed with this method
* prior to its containing activity saving its state. If the commit is
* attempted after that point, an exception will be thrown. This is
* because the state after the commit can be lost if the activity needs to
* be restored from its state. See {@link #commitAllowingStateLoss()} for
* situations where it may be okay to lose the commit.</p>
- 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
- Using R — Calling C Code ‘Hello World!’
- Apache (支持IPv6) 安装及常见错误
- log4j:WARN No appenders could be found for logger
- Google 地理信息反解析
- 实现HTTP断点续传下载工具(附源代码)
- Can not perform this action after onSaveInstanceState
- 互联网创业准备
- cordova调用Notification插件部分手机报错JNI ERROR (app bug): accessed stale local reference
- shell 函数返回值接收问题
- Codeforces Round#288(Div.2)
- 二叉查找树
- c#序列化和反序列化
- Linux下程序调试相关工具与技巧
- 对面向切面编程的简单理解