问题描述
我的活动调用与ACTION_IMAGE_CAPTURE意图相机。如果相机活动成功地返回,我在回调的onActivityResult设置一个标志,并根据标志的值,我开始一个片段在我onResume一个标题添加到被拍摄的图像。这似乎工作确定。
My activity invokes the camera with the ACTION_IMAGE_CAPTURE intent. If the camera activity returns succesfully, I set a flag in the onActivityResult callback, and based on the value of the flag I start a fragment in my onResume to add a caption to the image that was captured. This seems to work ok.
我刚刚得到一个堆栈跟踪从野抱怨说我是想的onSaveInstanceState被称为后提交片段事务。但我在做我的onResume方法提交!为什么会抱怨的android这个?我有的android:configChanges =方向| keyboardHidden |键盘|屏幕尺寸在我的AndroidManifest.xml中设定,所以改变方向时,不应触发这个....
I just got a stack trace from the "wild" complaining that I was trying to commit a fragment transaction after onSaveInstanceState has been called. But I'm doing the commit in my onResume method! Why would android complain about this? I do have android:configChanges="orientation|keyboardHidden|keyboard|screenSize" set in my AndroidManifest.xml, so an orientation change should not trigger this....
这发生在三星Galaxy S3(SGH-I747)运行4.0.4
This occurred on a Samsung Galaxy S3 (SGH-i747) running 4.0.4
下面是堆栈:
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)
at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:548)
at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:532)
at com.Familiar.Android.FamiliarAppV1.AddPhotosActivity2.performFragmentTransition(AddPhotosActivity2.java:278)
at com.Familiar.Android.FamiliarAppV1.AddPhotosActivity2.switchToCaptionsFragment(AddPhotosActivity2.java:438)
at com.Familiar.Android.FamiliarAppV1.AddPhotosActivity2.onResume(AddPhotosActivity2.java:167)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1158)
at android.app.Activity.performResume(Activity.java:4544)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2448)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2486)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1187)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4514)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
at dalvik.system.NativeStart.main(Native Method)
任何帮助或智慧AP preciated。
Any help or wisdom is appreciated.
推荐答案
我觉得我知道答案 - 我用从V4兼容库的FragmentActivity,所以我需要执行我的片段交易onResumeFragments而不是在onResume。有人可以证实?
I think I know the answer - I'm using the FragmentActivity from v4 compatibility library, and so I need to perform my fragment transactions in onResumeFragments instead of in onResume. Can someone confirm?
这篇关于"不能执行及的onSaveInstanceState后QUOT这个动作; - 为什么我越来越从我的活动的onResume方法,这个异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!