Android Navigation Component + Login Flow + Nested BottomNavigationView
First of all you can check Conditional Navigation
Second of all, you can do it with only one nav_graph
. But you need only one Activity
for this. After that, you can check in it like this:
navController.addOnDestinationChangedListener { _, destination, _ -> if(destination.id == R.id.mainFragment){ if(userIsLoggedIn()){ //start LoginFragment //hide bottom navigation }else{ //show bottom navigation } } }
But your starter fragment should be MainFragment
and not LoginFragment
You can use
navController.setGraph(R.navigation.xxxx)
inside some navController
.