In the new Navigation architecture component, how to implement conditional navigation?
Currently I have a single activity with LoginFragment and HomeFragment. Based on a
You can add navigation listener inside your activity, and from there navigate to LoginFragment based on your conditions, like this:
findNavController(nav_host_fragment).addOnNavigatedListener { controller, destination ->
when(destination.id) {
R.id.HomeFragment-> {
if(someCondition) {
//Navigate to LoginFragment
}
}
}