How to prevent previous fragment to show up after pressing back button using navigation controller?
I am trying to use the navigation controller right now. I want to move from LoginFragment to HomeFragment . In LoginFragment I use this code below to move to HomeFragment . Navigation.findNavController(view).navigate(homeDestination) However, when I tap the back button in the HomeFragment , it will go back to LoginFragment , I expect that when I tap the button it will close the app. In old way, if I use activity instead of using Fragment , I usually do something like this to get that expected behaviour: val intent = Intent(this,HomeActivity::class.java) intent.flags = Intent.FLAG_ACTIVITY