1

I'm trying to avoid this exception throughout my code, even though I've only seen it triggered by some of my code sometimes:

java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState

As suggested by this blog post, I'm avoiding commit()ing any Fragment Transactions during my onLoadFinished() methods: http://www.androiddesignpatterns.com/2013/08/fragment-transaction-commit-state-loss.html

I'd like to set a delayWhatever boolean in an onPause(), check for it in onLoadFinished() and then do the delayed work (committing the Transaction) when I know that the instance state has been restored.

That's fine when I'm in an Activity because I can do the delayed work in onResumeFragment(). But I have nested fragments (An Activity containing a Fragment containing 2 other Fragments). So where is it safe to commit transactions if my onLoadFinished() is in my Fragment, not the parent Activity()?

murrayc
  • 2,103
  • 4
  • 17
  • 32
  • It's possible that you are seeing something similar to me. Fragment showing DialogFragment getting the IllegalStateException. Except I have an even simpler case than you. http://stackoverflow.com/questions/27329913/dialogfragshow-from-onclick-throwing-illegalstateexception-can-not-perfor – William Dec 06 '14 at 09:38
  • Very possibly. Note that I _am_ using getChildFragmentManager() because I'm using child fragments. This seems like something that Android should be taking care of for us. – murrayc Dec 06 '14 at 14:22
  • Bugger. I was really hoping the `getChildFragmentManager()` was my get out of jail free on this one. Are you using `setTargetFragment` at all? – William Dec 06 '14 at 14:24
  • No, I'm not using setTargetFragment(). – murrayc Dec 07 '14 at 19:15

0 Answers0