OBS: Though still no first class support (as of writing this), Google has now updated their samples with an example of how they think this should be solved: https://github.com/googlesamples/android-architecture-components/tree/master/NavigationAdvancedSample
The Android Codelab for Navigation does a good job describing how to use the architecture component Navigation together with a BottomNavigationView
. But let's say I have 2 tabs in the BottomNavigationView
, Tab1 and Tab2. And let's say that in Tab1 you navigate through the fragments Frag1 --> Frag2. Now, whenever I go to Tab2, and then back to Tab1, the fragment back stack of Frag1,2 is gone, and replaced with the starting point Frag1 again.
What do I have to do in an app so that a BottomNavigationView
together with Navigation keeps its back stack intact even though I change tabs? And, also keeping the back/up button behaviours in sync with the guidelines.
Previously I've done this with the use of ViewPager
and managing the back stack my selfe, but that doesn't feels like the right approach with the new Navigation.
Thanks in advance!
Edit:
There's a more elaborate answer here.