0

I'm trying to implement this solution using Google Jetpack Navigation component and still struggle with back stack issue.

The problem I'm facing is a custom implementation of navigating method in FragmentNavigator class breaks existing logic of back stack.

if I try to add simple behavior like:

transaction.addToBackStack(tag)

then BottomNavigationView is not highlighting/selecting buttons properly for a current active fragment when the back button is pressed.

My question how to implement properly custom back stack using such approach that works correctly with BottomNavigationView and properly using the back pressed listener to override more advanced custom back stack that put right navigation in the same BottomNavigationView?

The naive approach would be override onBackPressed in activity and then just create own logic separately and manually use navController.navigate to simulate back stack functionality, but I would like to hear how this problem can be solved with BottomNavigationView, NavController, NavHostFragment, FragmentNavigator scope.

Tanveer Munir
  • 1,956
  • 1
  • 12
  • 27
Arsenius
  • 4,972
  • 4
  • 26
  • 39

0 Answers0