Hi. Using navigation: ``` NavHost(...
# compose
a
Hi. Using navigation:
Copy code
NavHost(
                    navController = navController,
                    startDestination = "splash"
                ) {
                    composable(Navigation.ROUTE_SPLASH) { InitScreen(navController) }
                    composable(Navigation.ROUTE_LOGIN) { LoginScreen(navController) }
                    composable(Navigation.ROUTE_USER) { UserScreen(navController) }
                    composable(Navigation.ROUTE_GO_WALK) { GoWalkScreen(navController) }
                }
From splash I navigate to login or user..., but when I hit the back button of the devices it goes again to splash. How can avoid that, and if I'm at login, or User close the app when back button is hit
i
As per the Principles of Navigation (https://developer.android.com/guide/navigation/navigation-principles#fixed_start_destination), you shouldn't be using a splash screen or login destination as your start destination. We talk about why this doesn't work in the Navigating Navigation video (

https://youtu.be/09qjn706ITA?t=272

) and that also applies to Compose
a
Uhmm, ok thanks, i will watch it
i
The documentation page on Conditional Navigation (i.e., navigating from your actual start screen to the login screen only when necessary) is also the recommended approach in Compose Navigation
But you might also look at the documentation for Compose Navigation, which covers how you can pop destinations off the back stack when you navigate: https://developer.android.com/jetpack/compose/navigation#nav-to-composable
a
Ok nice, so basically repeat the "no logged case" to anywhere auth is needed
i
Yeah, due to how Android restores state (not to mention cases like deep links), there's no guarantee that you'll actually have gone through that destination during your process's lifetime
a
thanks
a
hi, similar problem here but i am new to android. Did you manage to make it work?