I have this tabbed UI with a navigation component and a BottomNavigationView that handles the tabs.
My use case involves one of these tab fragments to have a BottomNavigationView of its own.
I don't think the nested navigation graphs will work for me because I need there to be an inner NavHostFragment and a second BottomNavigationView.
So I'm in the fragment which I wish to host my inner navigation graph. It contains a fragment like so.
<androidx.fragment.app.FragmentContainerView
android:id="@+id/inner_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
app:defaultNavHost="true"
I need a way to get the navigation controller for the above fragment.
Normally when you're in an activity you'd call the findFragmentById from the supportFragmentManager with the id you gave to your fragment.
val navHostFragment = supportFragmentManager.findFragmentById(R.id.outer_nav_host) as NavHostFragment
So I tried to call that on the activity object from within my inner fragment
requireActivity().supportFragmentManager.findFragmentById(R.id.inner_host_fragment)
But the findFragmentById returns null.