- Adding to above official documentation, we can also pass popUpto params in navOptionsBuilder
navController.navigate(
R.id.action_fragmentOne_to_fragmentTwo, // Destination Id
null, // Arguments that needs to be passed to destination
navOptions {
anim { // Animation options
enter = android.R.animator.fade_in
exit = android.R.animator.fade_out
}
popUpTo(R.id.fragmentOne) { // Pop all navigation stack back to fragmentOne
inclusive = false // Don't pop fragmentOne from stack
}
}
)