I'm using navigation in MainActivity
, then I start SecondActivity
(for result). After finish of SecondActivity
I would like to continue with navigation in MainActivity
, but FragmentManager
has saved his state already.
On Navigation.findNavController(view).navigate(R.id.action_next, bundle)
I receive log message:
Ignoring navigate() call: FragmentManager has already saved its state
How I can continue in navigation?
Finally, I fix the issue by simple calling
super.onPostResume()
right before navigating to restore state.I've solved this problem this way:
and then
not sure, if this is not a terrible hack, but it worked for me. FramgentManager state is restored at this point (onResume) and no problems with navigation occur.
You must always call
super.onActivityResult()
in your Activity'sonActivityResult
. That is what:Unlocks Fragments so they can do fragment transactions (i.e., avoid the
state is already saved
errors)Dispatches
onActivityResult
callbacks to Fragments that calledstartActivityForResult
.