-
Notifications
You must be signed in to change notification settings - Fork 59
Description
I implemented the worker fragment approach in my project based in your 'extra' of this project.
I have Activity A
that has a Fragment A
. That fragment starts a worker fragment.
But, if I start some other activity and come back to Activity A, I get this
exception:
java.lang.IllegalStateException: Failure saving state: "WorkerFragment" has target not in fragment manager: "FragmentA"
I googled about this and the workaround for that problem was to put in
onDetach()
of my Fragment A
this: workerFragment.setTargetFragment(null, -1);
But, if now I open another activity and come back to Activity A
, then, rotates
the screen, I get an exception, because now, of course, getTargetFragment() == null
.
So, I added this verification in onAttach()
of Worker fragment: if (getTargetFragment() != null) {}
In this way, I don't get any exceptions, but I need to know: Is this the expected behavior or I'm missing something?
Thanks