IllegalStateException: Can not perform this action after onSaveInstanceState
来源:互联网 发布:姚明赛季数据 编辑:程序博客网 时间:2024/06/06 11:45
今天使用Fragment的时候,调用出现popBackStackImmediate方法出现了IllegalStateException: Can not perform this action after onSaveInstanceState,在网上了搜了很久,其中http://stackoverflow.com/questions/7575921/illegalstateexception-can-not-perform-this-action-after-onsaveinstancestate-wit应该是其中最权威的解决的方案,但试了里面的方法依然解决不了,猜想应该是我的Fragment是Fragment中的Fragment中的Fragment,也就是层层嵌套下的Fragment。
没有办法只能看源码了,通过源码我们可以发现那个异常是因为mStateSaved这个属性是true才导致的,我们只需要把mStateSaved用反射改为false就行了。
下面就解决办法的源码当然这方法最多算个治标不治本的方法,Fragment还有很多细节是我不知道的,需要不断加强的学习,这个坑爹的方法暂时用着先吧。try { FragmentManager manager = getFragmentManager(); Log.e(TAG, "class " + manager.getClass()); Field field = manager.getClass().getDeclaredField("mStateSaved"); field.setAccessible(true); field.set(manager, false); getFragmentManager().popBackStackImmediate(); } catch (Exception e) { e.printStackTrace(); }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
- Main函数参数argc,argv用法
- 第六届蓝桥杯软件类省赛真题-C-B-7_牌型种数
- Introduction to Ambisonics
- 关于iOS中的图片格式,一个合格的开发者必须知道的5个知识点
- bzoj1011 [HNOI2008]遥远的行星
- IllegalStateException: Can not perform this action after onSaveInstanceState
- JavaScript算法详解——快速排序
- [学习笔记]JAVA_SSM框架简单的登录拦截器配置
- windows 安全模型简介
- JavaScript函数
- 第六届蓝桥杯软件类省赛真题-C-B-1_奖券数目
- POJ 2928 A City of Skyscrapers 可能会
- Android--获取当前系统时间
- 鸟哥的Linux私房菜基础篇笔记--8