Cross navigation between two different Navigation Graph in Android

Viewed 9

Thanks for paying attention to this question:

Have 2 different navigation graphs:

First Navigation Graph: navigation_dashboard.xml

<?xml version="1.0" encoding="utf-8"?>

<fragment
    android:id="@+id/fragmentHome"
    android:name="com.example.genu.FragmentHome"
    android:label="fragment_home"
    tools:layout="@layout/fragment_home" >
    <action
        android:id="@+id/action_fragmentHome_to_fragmentProfile"
        app:destination="@id/fragmentSecond" />
</fragment>
<fragment
    android:id="@+id/fragmentProfile"
    android:name="com.example.genu.ProfileFragment"
    android:label="fragment_profile"
    tools:layout="@layout/fragment_profile" />

Second Navigation Graph: gallery_navigation.xml

<?xml version="1.0" encoding="utf-8"?>

<fragment
    android:id="@+id/myGalleryFragment"
    android:name="com.generationunified.genu.MyGalleryFragment"
    android:label="fragment_my_gallery"
    tools:layout="@layout/fragment_my_gallery" >
    <action
        android:id="@+id/action_myGalleryFragment_to_myHistoryFragment"
        app:destination="@id/myHistoryFragment" />
</fragment>

<fragment
    android:id="@+id/myHistoryFragment"
    android:name="com.generationunified.genu.MyHistoryFragment"
    android:label="fragment_my_history"
    tools:layout="@layout/fragment_my_history" />

DashBoardActivity holds navigation_dashboard and GalleryActivity holds navigation_gallery

Now, Let's say we are in HistoryFragment which belongs to GalleryActivity and wants to open the ProfileFragment which belongs to DashBoardActivity

How to achieve above mentioned navigation? Any help would be really really appreciated....

Please have a look at below diagram for better understanding:

enter image description here

0 Answers
Related