In my application i am using Jetpack Navigation with BottomNavigationView. I have like 5 fragments and when i am in Home fragment, i click tab2 item in bottom navigation view and i click tab1 again, it re-creates the fragment.
val navHostFragment = supportFragmentManager.findFragmentById(
R.id.nav_host_container
) as NavHostFragment
navController = navHostFragment.navController
navController.addOnDestinationChangedListener { _, destination, _ ->
currentNavId = destination.id
}
binding.bottomNav.setupWithNavController(navHostFragment.navController)
binding.bottomNav.apply {
setupWithNavController(navController)
setOnItemReselectedListener { }
}
