I have a BottomSheetDialogFragment that contains a NavHostFragment like so:
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/add_feeling_nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
app:defaultNavHost="true"
app:navGraph="@navigation/add_feeling_graph" />
</LinearLayout>
</layout>
When I try to get the NavController in it's class using either of the following:
activity?.findNavController(R.id.add_feeling_nav_host_fragment)
view.findNavController()
The first option crashes because it cannot find the ID and the second one does finds a parent Nav Controller and uses that.
I have an identical setup for another Fragment however it's not a dialog and it works perfectly. Any ideas to what the issue could be? Thanks