bug_ _fragment的1
========= 2 fragment小结 ????
======== 1 fragment:java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
- Bundle b = new Bundle();
- b.putParcelable("bitmap", bitmap2);
- imageRecognitionFragment.setArguments(b);
设置好参数,并且添加hide(), add()方法之后,需要commit(),来实现两个Fragment跳转的时候,这种情形下参数需要进行系统保存,但是这个时候你已经实现了跳转,系统参数却没有保存。此时就会报
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState异常。
使用: trans.commitAllowingStateLoss(); 代替:trans.commit();
========== 1 java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at android.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1328)
at android.app.FragmentManagerImpl.popBackStackImmediate(FragmentManager.java:497)
at android.app.Activity.onBackPressed(Activity.java:2525)
at com.foryou.agent.activity.BaojiaActivity$1.onClick(BaojiaActivity.java:111)
at android.view.View.performClick(View.java:4793)
at android.view.View$PerformClick.run(View.java:19948)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5593)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:967)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)
今天使用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 ()
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()就行了,其效果是一样的。
bug_ _fragment的1的更多相关文章
- android fragment传递参数_fragment之间传值的两种方法
在Activity中加载Fragment的时候.有时候要使用多个Fragment切换.并传值到另外一个Fragment.也就是说两个Fragment之间进行参数的传递.查了很多资料.找到两种方法.一种 ...
- bug_ _ _常见的bug??
======= 7 Failure [INSTALL_FAILED_INVALID_APK] 执行 adb install -r test.apk.时出现错误 Failure [INSTAL ...
- bug_ _org.json.JSONException: End of input at character 0 of
10-16 18:28:39.549: W/System.err(4950): org.json.JSONException: End of input at character 0 of 10-16 ...
- bug_ _
java.lang.SecurityException: Not allowed to bind to service I app中加了百度定位功能,大部分手机测试没问题,但有部分手机会定位失败,提示 ...
- 安卓开发_慕课网_Fragment实现Tab(App主界面)
学习内容来自“慕课网” 这里用Fragment来实现APP主界面 思路: 底部横向排列4个LinearLayout,每个LinearLayout包含一个图片按钮和一个文字 1.默认显示第一个功能(微信 ...
- bug_ _图片_android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>
=========== 1 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.zgan.communit ...
- bug_ _小心android-support-v4.jar版本混乱造成的NoClassDefFoundError
当你的项目出现以下红色提示的时候,要小心了, 因为很可能因为这个错误而导致解释不通的异常出现. Found 2 versions of android-support-v4.jar in the de ...
- bug_ _fragment_“The specified child already has a parent. You must call removeView"的解决以及产生的原因
这个异常的出现往往是因为非法使用了某些方法引起的. 从字面意思上是说这个特定的child已经有一个parent了,你必须在这个parent中首先调用removeView()方法,才能继续你的内容.这里 ...
- bug_ _ java.lang.IllegalArgumentException: pointerIndex out of range 问题的两种解决办法
========== 4 如何解决java.lang.IllegalArgumentException: pointerIndex out of range? 今天遇到一个bug:java.l ...
随机推荐
- [POI 2008][BZOJ 1132]Tro
这题我真是无能为力了 这题的做法还是挺简单的 枚举左下角的点做为原点,把其余点按极角排序 PS.是作为原点,如枚举到 k 时,对于所有 p[i] (包括p[k]) p[i]-=p[k] (此处为 ...
- C/C++笔试题(很多)
微软亚洲技术中心的面试题!!! .进程和线程的差别. 线程是指进程内的一个执行单元,也是进程内的可调度实体. 与进程的区别: (1)调度:线程作为调度和分配的基本单位,进程作为拥有资源的基本单位 (2 ...
- Unity坐标系
Unity 使用的是左手坐标系
- Tensorflow 上手——手写数字识别
下面代码是Tensorflow入门教程中的代码,实现了一个softmax分类器. 第4行是将data文件夹下的mnist数据压缩包读取为tf使用的minibatch字典. 第6-11行定义了所用的变量 ...
- Python编程规范(PEP8)
Python编程规范(PEP8) 代码布局 缩进 对于每一次缩进使用4个空格.使用括号.中括号.大括号进行垂直对齐,或者缩进对齐. 制表符还是空格? 永远不要将制表符与空格混合使用.Python最常用 ...
- 06-Java 本地文件操作
1.File类简介 创建好:File file=new File("hello.txt"); 后,按住Ctrl键.单击File.会出现File的源代码. 在视图左下角双击" ...
- 无法启动:此实现不是Windows平台FIPS验证的加密算法的一部分
个别同学可能会在启动订票助手.NET的时候发现这个提示: 出现这个问题的原因是订票助手.NET使用了MD5算法,而系统的组策略安全设置导致无法使用此算法.要修正此问题,请按照如下操作(两种方法任选其一 ...
- linux设置系统日期时间
设置当前日期: date -s 08/06/2015 设置当前时间:date -s 10:03:00 写入BIOS: clock -w 显示当前日期时间: date
- intellij idea +maven4+springmvc4搭建
0.淘宝mave培训PPT http://www.open-open.com/doc/view/4058453cde4b429c82ff2807d8aa81f0 1.intellij创建空的maven ...
- Oracle自增主键的添加[sequence]--表数据已存在
--增加主键ID ); --设置sequence使ID自增 create sequence SEQ_ID minvalue maxvalue start ; --将id的值设置为sequence Up ...