I'm using Android Navigation Component. There is one activity with FragmentContainerView(NavHostFragment) with simple navigation flow by common_navigation_graph
But on one fragment there is a nested NavHostFragment and BottomNavigationView. Reason for that - I want to have 3 tabs on the fragment. Bottom navigation configure with own navController and separate navigation_graph
val navController = activity?.findNavController(R.id.navHostViewPagerView)
binding?.bottomNavigation?.setupWithNavController(navController!!)
On each Tab there is a one more nested fragment with own FragmentContainerView and it's own small tab_navigation_graph
Navigation scheme looks:
[enter image description here][1]
[1]: https://i.stack.imgur.com/gmXOY.png
In general it works pretty well. Navigation between tabs, navigation in some selected Tab works well, back stack works well
override fun handleOnBackPressed() {
view?.findNavController()?.popBackStack()
}
But since there was a navigation to some next fragment from common_navigation_graph(SomeNextFragment on the picture) the backStack flow will be broken.
I will be able to return to fragment with Tabs, but backStack flow for nested fragments in the Tab will not work. Only the last fragment will be displayed(Tab1.2) Transition by Blue arrow not working.
On handleOnBackPressed() view==null and fragment.id==0. Fragment was destroyed
Question is how to save ability to navigate through nested Tab fragments on come back from other fragmnet from common_navigation_graph
question from:
https://stackoverflow.com/questions/65844360/issue-with-back-stack-flow-using-navigation-component-and-bottomnavigationview 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…