Reputation: 4587
I'm still apparently not clear on handling fragments along with other things going on in my activity. The following is the stack trace:
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=2, result=-1, data=Intent { (has extras) }} to activity {com.ghcssoftware.gedstar/com.ghcssoftware.gedstar.GedStar}: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at android.app.ActivityThread.deliverResults(ActivityThread.java:2747)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:2790)
at android.app.ActivityThread.access$2000(ActivityThread.java:122)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1035)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:132)
at android.app.ActivityThread.main(ActivityThread.java:4028)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:491)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1299)
at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1310)
**at android.support.v4.app.FragmentManagerImpl.popBackStack(FragmentManager.java:471)
at com.ghcssoftware.gedstar.PersonTab$PersonTabFrag.popStack(PersonTab.java:157)**
at com.ghcssoftware.gedstar.PersonTab$PersonTabFrag.fillData(PersonTab.java:165)
at com.ghcssoftware.gedstar.ViewTab.fillData(ViewTab.java:96)
at com.ghcssoftware.gedstar.GedStar.fillData(GedStar.java:589)
at com.ghcssoftware.gedstar.GedStar.onActivityResult(GedStar.java:514)
at android.app.Activity.dispatchActivityResult(Activity.java:4541)
at android.app.ActivityThread.deliverResults(ActivityThread.java:2743)
So this looks like it is my call to popBackStack within this function where I'm cleaning out any stacked fragments in one of my view panes:
// Pop fragments from second pane
private void popStack() {
if (mDualPane && mBottomId >= 0) {
mViewTab.getTabHelper().tabGetFragManager().popBackStack(mBottomId,
FragmentManager.POP_BACK_STACK_INCLUSIVE);
mBottomId = -1;
}
}
Mainly I'm not sure why any of this is occurring "after onSaveInstanceState" has been called, or if that's what's really happening. Any possible explanations? Would popBackStackImmediate make a difference?
For what it's worth, I have not been able to recreate the circumstances in my testing, so it's only showing up in the reports.
Upvotes: 12
Views: 10442
Reputation: 405735
The problem, which is evident from looking at the trace, is that I was calling popStack from code in my onActivityResult method, which is called before onResume. I moved the call to onResume and fixed it.
Upvotes: 15