In my application i am using Jetpack Navigation with BottomNavigationView
. I have like 4 fragments:Home,Search,Notifications,Profile and when i am in Home fragment, i click again home item in bottom navigation view, it re-creates the fragment. I searched, but mainly answers were for those who did not use jetpack navigation.
(by the way, i only want fragment not being re-created when i am on that fragment already, if i am not in that fragment, it is okay to be re-created)
Below is my setup:
val navHostFragment = supportFragmentManager.findFragmentById(R.id.fragmentContainerView_mainActivity) as NavHostFragment
navController = navHostFragment.navController
binding.bottomNavView.setupWithNavController(navController)