I tried use Android Navigation component and have a problem with back stack.
I have Fragment A, B. I write:
Navigation.findNavController(view).navigate(R.id.a_to_b)
It's ok. But if I want return to A, i call:
Navigation.findNavController(view).popBackStack();
Then in fragment B will be calling onViewStateRestored with null state why?
I want to keep state when calling navigate to Fragment A.
navigateUp() Attempts to navigate up in the navigation hierarchy. @MainThread boolean. popBackStack()
NavController is the class which deals with the FragmentManager or FragmentTransaction. NavController manages application navigation with the NavHostFragment. Navigation flow and destination are determined by the navigation graph owned by the NavController class.
try this
val controller = Navigation.findNavController(view)
controller.popBackStack(R.id.id_of_fragment_which_you_want_to_skip, true)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With