今天做项目中的支付宝功能,是在fragment中做的,在支付成功后,想切换到支付成功的页面。

结果就报错了IllegalStateException: Can not perform this action after onSaveInstanceState:

在网上找了下解决方案,将commit改成了 commitAllowingStateLoss()就没问题了,贴出原帖地址http://www.ablanxue.com/prone_7000_1.html,参考。

今天使用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:的更多相关文章

  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

    http://www.cnblogs.com/zgz345/archive/2013/03/04/2942553.html 今天使用Fragment的时候,出现了这个错误 IllegalStateEx ...

  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. JAVA中关于Map的九大问题

    通常来说,Map是一个由键值对组成的数据结构,且在集合中每个键是唯一的.下面就以K和V来代表键和值,来说明一下java中关于Map的九大问题. 0.将Map转换为List类型 在java中Map接口提 ...

  2. JS实现复制到剪贴板

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...

  3. 通过在shell脚本中用scp或rsync实现远程同步文件

    通过在shell脚本中用expect实现远程scp文件  shell expect的简单用法 http://myunix.blog.51cto.com/191254/1095074 http://ji ...

  4. nyoj 60 谁获得了最高奖学金

    谁获得了最高奖学金 时间限制:1000 ms  |  内存限制:65535 KB 难度:2   描述     某校的惯例是在每学期的期末考试之后发放奖学金.发放的奖学金共有五种,获取的条件各自不同: ...

  5. [iOS基础控件 - 4.5] 猜图游戏

    A.需要掌握的 1.添加图片资源(暂时认为@2x跟非@2x代表同一张图片) 2.搭建UI界面* 文本标签* 4个按钮* 中间的图片 3.设置状态栏样式 4.监听下一题按钮的点击 5.延迟加载数据* 加 ...

  6. [OC Foundation框架 - 14] NSNull

    在NSDictionary中,nil代表结束,允许存入 使用NSNull代替   int main(int argc, const char * argv[]) { @autoreleasepool ...

  7. 偶遇mysql外键不好使

    原来是创建表时选择的类型不一样,应该是innoDB,而且关联的主表类型也必须是innoDB

  8. [css]《CSS知多少》

    http://www.cnblogs.com/wangfupeng1988/p/4325007.html

  9. MSSQLSERVER数据库- 触发器

    参考了别人写的文章,我删除掉一些废话,只看一些我想看的信息.整理了一下,记录在这里,方便以后查阅! 1.当触发INSERT触发器时,新的数据行就会被插入到触发器表和inserted表中. 2.当触发d ...

  10. git 回退和删除操作

    今天不小心把分支的commit提交到master上了.衰 主要通过下面几个命令解决了,很简单记录一下. git reset –hard  回退到某一个版本git push origin :xxxx  ...