解决IllegalStateException: Can not perform this action after onSaveInstanceState
今天使用Fragment的时候,出现了这个错误 IllegalStateException: Can not perform this action after onSaveInstanceState:
- E/AndroidRuntime(12747): Caused by: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
- at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1314)
- at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1325)
是在使用FragmentTransition的 commit方法添加一个Fragment的时候出现的,后来在官网找到了相关的
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的更多相关文章
- 【转】 解决IllegalStateException: Can not perform this action after onSaveInstanceState
今天使用Fragment的时候,出现了这个错误 IllegalStateException: Can not perform this action after onSaveInstanceState ...
- 解决IllegalStateException: Can not perform this action after onSaveInstanceState:
今天做项目中的支付宝功能,是在fragment中做的,在支付成功后,想切换到支付成功的页面. 结果就报错了IllegalStateException: Can not perform this act ...
- IllegalStateException: Can not perform this action after onSaveInstanceState
http://www.cnblogs.com/zgz345/archive/2013/03/04/2942553.html 今天使用Fragment的时候,出现了这个错误 IllegalStateEx ...
- java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState问题解决
(1)我用的是fragment,在onStop但是没有onDestroy的情况下切换(replace)fragment时报 java.lang.IllegalStateException: Can n ...
- Android 错误:IllegalStateException: Can not perform this action after onSaveInstanceState
今天做Fragment切换.状态保存功能的时候,出现了这个错误: E/AndroidRuntime(12747): Caused by: java.lang.IllegalStateException ...
- java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState解决?
做项目到最后整合的时候测试的时候发现 切换tab更换fragment的时候抛出了这个异常,根据异常信息Can not perform this action after onSaveInstance ...
- java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
在使用Fragment的过程中,常常会遇到在Activity的onSaveInstanceState方法调用之后,操作commit或者popBackStack而导致的crash. 因为在onSaveI ...
- Can not perform this action after onSaveInstanceState
java.lang.RuntimeException: Unable to resume activity {com.tongyan.nanjing.subway/com.tongyan.struct ...
- android异常:Can not perform this action after onSaveInstanc
extends:http://zhiweiofli.iteye.com/blog/1539467 本人某个android项目开发阶段一直运行良好,直到上线前夕,在某款跑着android 4.03系统的 ...
随机推荐
- php生成二维码可以有以下几种方式
1.google开放api $urlToEncode="http://bbs.lewanchina.com"; generateQRfromGoogle($urlToEncode) ...
- SQL2008 强烈要求限制最大内存
64位开了AWE没什么潜在问题,另外最大内存设置强烈要求改掉,不要用默认的,一般留2~3G内存给操作系统.你是怎么看到20多G是被awe用了的? 如果内存大的话,只留1GB给OS会有问题,可以参考下面 ...
- WEB用户访问控制方法
分享到 一键分享 QQ空间 新浪微博 百度云收藏 人人网 腾讯微博 百度相册 开心网 腾讯朋友 百度贴吧 豆瓣网 搜狐微博 百度新首页 QQ好友 和讯微博 更多... 百度分享 一直以来,我对用户/权 ...
- 06socket编程
socket可以看成是用户进程与内核网络协议栈的编程接口. socket不仅可以用于本机的进程间通信,还可以用于网络上不同主机的进程间通信. IPv4套接口地址结构通常也称为“网际套接字地址结构”,它 ...
- JQ查找替换
resultStr = resultStr.replace(/\n/gi , "<br />"); //可以全部替换resultStr = resultStr.repl ...
- 单源最短路径——Floyd算法
正如我们所知道的,Floyd算法用于求最短路径.Floyd算法可以说是Warshall算法的扩展,三个for循环就可以解决问题,所以它的时间复杂度为O(n^3). Floyd算法的基本思想如下:从任意 ...
- ie浏览器的渲染原理
IE下载或者渲染顺序大致如下: IE下载的顺序是从上到下,渲染的顺序也是从上到下,下载和渲染是同时进行的. 在渲染到页面的某一部分时,其上面的所有部分都已经下载完成(但并不是说所有相关联的元素都已经下 ...
- (C/C++) Interview in English - Points.
Q: What is a dangling pointer? A: A dangling pointer arises when you use the address of an object af ...
- SchemaExport的使用
@Test public void testCreateDB(){ Configuration cfg = new Configuration().configure(); SchemaExport ...
- [Java Web – Maven – 1A]maven 3.3.3 for windows 配置(转)
1.环境 系统环境:windows 2008 R2 JDK VERSION: 1.7.0_10 2.下载地址 MAVEN 下载地址:http://maven.apache.org/download.c ...