When I use backStackEntryCount > 1. popbackstack() it is not navigating to any of the fragments of my bottom navigation
What I need to know is, how to stack fragments one time only, so I can press the back button once which will be navigating to the Activity.
private fun navBottomClick() { bottomNavigationView?.setOnItemSelectedListener { when (it.itemId) { R.id.workout -> { var fragmentTransaction: FragmentTransaction = supportFragmentManager.beginTransaction() fragmentTransaction.replace(R.id.container, WorkoutFragment(), "WORKOUT") fragmentTransaction.addToBackStack("WORKOUT") fragmentTransaction.commit() } R.id.health -> { var fragmentTransaction: FragmentTransaction = supportFragmentManager.beginTransaction() fragmentTransaction.replace(R.id.container, HealthyFoodFragment(), "HealthFood") fragmentTransaction.addToBackStack("HealthFood") fragmentTransaction.commit() } } true } }