http://www.cnblogs.com/zgz345/archive/2013/03/04/2942553.html

今天使用Fragment的时候,出现了这个错误 IllegalStateException: Can not perform this action after onSaveInstanceState:

  1. E/AndroidRuntime(12747): Caused by: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
  2. at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1314)
  3. at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1325)

是在使用FragmentTransition的 commit方法添加一个Fragment的时候出现的,后来在官网找到了相关的

说明:http://developer.android.com/reference/android/app/FragmentTransaction.html#commitAllowingStateLoss()

public abstract int commitAllowingStateLoss ()

Added in API level 11

Like commit() but allows the commit to be executed after an activity's state is saved. This is dangerous because the commit can be lost if the activity needs to later be restored from its state, so this should only be used for cases where it is okay for the UI state to change unexpectedly on the user.

大致意思是说我使用的 commit方法是在Activity的onSaveInstanceState()之后调用的,这样会出错,因为

onSaveInstanceState方法是在该Activity即将被销毁前调用,来保存Activity数据的,如果在保存玩状态后

再给它添加Fragment就会出错。解决办法就是把commit()方法替换成 commitAllowingStateLoss()就行

了,其效果是一样的。

IllegalStateException: Can not perform this action after onSaveInstanceState的更多相关文章

  1. 解决IllegalStateException: Can not perform this action after onSaveInstanceState

    今天使用Fragment的时候,出现了这个错误 IllegalStateException: Can not perform this action after onSaveInstanceState ...

  2. 【转】 解决IllegalStateException: Can not perform this action after onSaveInstanceState

    今天使用Fragment的时候,出现了这个错误 IllegalStateException: Can not perform this action after onSaveInstanceState ...

  3. 解决IllegalStateException: Can not perform this action after onSaveInstanceState:

    今天做项目中的支付宝功能,是在fragment中做的,在支付成功后,想切换到支付成功的页面. 结果就报错了IllegalStateException: Can not perform this act ...

  4. java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState问题解决

    (1)我用的是fragment,在onStop但是没有onDestroy的情况下切换(replace)fragment时报 java.lang.IllegalStateException: Can n ...

  5. Android 错误:IllegalStateException: Can not perform this action after onSaveInstanceState

    今天做Fragment切换.状态保存功能的时候,出现了这个错误: E/AndroidRuntime(12747): Caused by: java.lang.IllegalStateException ...

  6. java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState解决?

    做项目到最后整合的时候测试的时候发现  切换tab更换fragment的时候抛出了这个异常,根据异常信息Can not perform this action after onSaveInstance ...

  7. java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState

    在使用Fragment的过程中,常常会遇到在Activity的onSaveInstanceState方法调用之后,操作commit或者popBackStack而导致的crash. 因为在onSaveI ...

  8. Can not perform this action after onSaveInstanceState

    java.lang.RuntimeException: Unable to resume activity {com.tongyan.nanjing.subway/com.tongyan.struct ...

  9. android异常:Can not perform this action after onSaveInstanc

    extends:http://zhiweiofli.iteye.com/blog/1539467 本人某个android项目开发阶段一直运行良好,直到上线前夕,在某款跑着android 4.03系统的 ...

随机推荐

  1. BZOJ 1086 王室联邦 | BFS

    BZOJ 1086 王室联邦 题意 把一棵树分块,每块大小在[B, 3B]之间(B由输入数据给出),每个块需要对应一个核心点,核心点可以在块内,这个点要满足块内每个点到核心点的路径上的点都属于这个块( ...

  2. 【LOJ】#2128. 「HAOI2015」数字串拆分

    题解 题中给的函数可以用矩阵快速幂递推 我们记一个数组dp[i](这个数组每个元素是一个矩阵)表示从1到i所有的数字经过拆分矩阵递推的加和 转移方法是 \(dp[i] = \sum_{j = 0}^{ ...

  3. linux修改文件读写执行权限命令chmod

    之前用chmod的时候都是简单的类似下面这样使用: $ file 也有时候可能会修改一个目录下所有子目录和文件: $ directory -R 也知道3个数字(例子中的755)分别代表赋予 “文件属主 ...

  4. Ubuntu 16.04设置rc.local开机启动命令/脚本的方法

    Ubuntu 16.04设置rc.local开机启动命令/脚本的方法       Ubuntu 16.04设置rc.local开机启动命令/脚本的方法(通过update-rc.d管理Ubuntu开机启 ...

  5. JdbcTemplate使用小结

    org.springframework.jdbc.core.JdbcTemplate.query(String sql, Object[] args, RowMapper<StaffUnionV ...

  6. 命令:history

    简介 shell进程会在其会话中保存此前用户执行过的命令. 历史列表(history list):当前shell所使用的历史命令存储位置. 历史文件(history file):每次登入shell,就 ...

  7. 捕获程序异常之onerror

    问题描述:html5页面在电脑上打开,功能正常,没有报错,一旦嵌进微信或者APP,页面就卡住了,不好排查js问题. 预期结果:手机微信页面功能失效时,开发人员在console面板能明确看到出错信息,出 ...

  8. netbeans启动后一会崩溃处理

    由于netbeans 默认不支持amd cpu渲染,故需要修改默认配置文件,修改后netbeans没有问题. http://stackoverflow.com/questions/34560485/n ...

  9. 懒人的福利?教你用set维护斜率优化凸包

    斜率优化题目大家肯定都做得不少了,有一些题目查询插入点的x坐标和查询斜率都不单调,这样就需要维护动态凸包并二分斜率.(例如bzoj1492) 常规的做法是cdq分治或手写平衡树维护凸包,然而如果我不愿 ...

  10. enode

    WeText项目:一个基于.NET实现的DDD.CQRS与微服务架构的演示案例 WeText项目:一个基于.NET实现的DDD.CQRS与微服务架构的演示案例 https://mp.weixin.qq ...