I have bottom navigation in main Activity and have a data in MainActivity
and I want to pass that to HostFragments I am using NavigationExtensions form google NavigationAndvancedSample sample
here the extension function I am using in MainActivity but do you know how I can pass data which is the best way to pass data which intent contains to HostFragments? You can see I have fragmentTag and navigationHostFragment
fun BottomNavigationView.setupWithNavController(navGraphIds: List<Int>,
fragmentManager: FragmentManager,containerId: Int,intent: Intent)
private fun obtainNavHostFragment(
fragmentManager: FragmentManager,
fragmentTag: String,
navGraphId: Int,
containerId: Int
): NavHostFragment {
// If the Nav Host fragment exists, return it
val existingFragment = fragmentManager.findFragmentByTag(fragmentTag) as NavHostFragment?
existingFragment?.let { return it }
// Otherwise, create it and return it.
val navHostFragment = NavHostFragment.create(navGraphId)
fragmentManager.beginTransaction()
.add(containerId, navHostFragment, fragmentTag)
.commitNow()
return navHostFragment
}````