which has quite some code to support multiple back...
# android
r
which has quite some code to support multiple back stacks.
google 2
stackoverflow 2
r
Jetpack Navigation doesn't support multiple backstacks out of the box yet. We use separate (xml) navgraphs with the linked extension and so far it works.
r
Phew, together with a colleague after couple hours of debugging we found out the order nav graphs id's matter. We first got very weird behavior of multiple fragments on top of each other.
r
They have to match, yes. ^^
r
Well the nav graphs id's did match the bottom nav menu id's. But that's not enough. This order also needs to match:
Copy code
private fun setupBottomNavigationBar() {
    val navGraphIds = listOf(
            R.navigation.feed_nav_graph,
            R.navigation.discover_nav_graph,
            R.navigation.add_experience_nav_graph,
            R.navigation.trips_nav_graph,
            R.navigation.notifications_nav_graph)

    // Setup the bottom navigation view with a list of navigation graphs
    val controller: LiveData<NavController> = binding.globalBottomNav.setupWithNavController(
            navGraphIds = navGraphIds,
            fragmentManager = supportFragmentManager,
            containerId = R.id.global_nav_host_fragment,
            intent = intent
    )
r
That's what I meant, yep. I remember that Ian Lake said sometime it's necessary to rewrite parts of the fragment in order to support multiple backstacks out of the box. So I guess one has to live with that for now. ^^
f
It might messy to use just one activity this is how I break mine down if I have authentication I would create a graph to handle only auth then another graph for dashboard if dashboard has like account section and account has children I,LL create a graph to handle it children
Just to avoid mess and keep a clean code