I have three pages A, B and C, which are accessed sequentially through navigation.
A -> B -> C
How can I return from C to A?
These official descriptions should be useful, but don’t understand.
// Pop everything up to the "home" destination off the back stack before
// navigating to the "friends" destination
navController.navigate(“friends”) {
popUpTo("home")
}
// Pop everything up to and including the "home" destination off
// the back stack before navigating to the "friends" destination
navController.navigate("friends") {
popUpTo("home") { inclusive = true }
}
// Navigate to the "search” destination only if we’re not already on
// the "search" destination, avoiding multiple copies on the top of the
// back stack
navController.navigate("search") {
launchSingleTop = true
}
The navigation you are referring to shows how to clear the stack when navigating to a specific destination.
If you need to clear the navigation stack, you can use popBackStack as shown below:
navController.popBackStack(route = "A", inclusive = false)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With