IllegalStateException: Can not perform this action after onSaveInstanceState
来源:互联网 发布:矩阵的迹怎么求 编辑:程序博客网 时间:2024/05/21 20:22
出现这个问题的原因,看了下,可能是因为打开的界面太多,导致想要操作的界面进入了销毁状态,调用了onSaveInstanceState方法,将界面的信息保存起来,这时候,你再操作这个界面的UI,就会报错,因为界面已经处于销毁状态了,一切都是不可改变的。
常见例子:当应用打开之后,按Home键退出,如果马上再返回该应用,那么不一定会调用onSaveInstanceState进入销毁状态,但是如果Home键退出之后,很长时间都没有返回,那么系统为了内存考虑,肯定会将这个应用onSaveInstanceState掉,保存退出前的状态,这个时候你进行操作,就会报标题的错误。
解决方法:将需要进行的操作,在这个界面恢复之后进行调用,也就是Activity的onPostResume方法和FragmentActivity的onResumeFragments方法。这两个方法都会在Activity从它的销毁状态恢复过来后才会调用,因此可以避免状态丢失。
0 0
- 解决IllegalStateException: 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
- 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
- 解决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解决办法
- java.lang.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
- IllegalStateException: 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
- CCNP- 交换技术
- 操作系统的名字的读音
- CCNP-路由技术
- ExtJS学习笔记(十二) Ext 获取组件、获取DOM
- maven基础命令
- IllegalStateException: Can not perform this action after onSaveInstanceState
- 听说我们被黑成Unity汉化版了……
- js的概念
- Ant vs Maven vs Gradle比较
- cpu hotplug notifier
- CCNP-Frame-Relay
- Android中如何显示gif图片
- myeclipse项目外面有红叉,里面没有错误
- sse优化一例