Im building an app with conditional navigation based on the values of the login token received. So I have three different landing pages for my app based on three diffrent values i revceive after decoding the token. So Iam using three different activties each with its own set of Navigation Graphs and NavHostFragment. Problem is as soon as I declare another navhost fragment in second activity, app is crashing whenever that activity is opened, with error: "Binary XML file line #36: Duplicate id 0x7f09018a, tag null, or parent id 0xffffffff with another fragment for androidx.navigation.fragment.NavHostFragment"
Following is how I declare navhost fragment in first activity:
<fragment
android:id="@+id/nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/bottomNav"
android:layout_below="@+id/appbar"
app:defaultNavHost="true"
app:navGraph="@navigation/navigation_graph" />
And this is how I declare navhost fragment in second activity:
<fragment
android:id="@+id/nav_host_fragment_supervisor"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/bottomNav"
android:layout_below="@+id/appbar"
app:defaultNavHost="true"
app:navGraph="@navigation/navigation_graph_supervisor" />
Please help.
User contributions licensed under CC BY-SA 3.0