1

My application has 3 modules

  • app
  • authentication
  • home

app module has both other modules added in gradle

app module has main graph which contains nested graph from authentication and home module

I have login fragment in authentication module and I want to navigate to home fragment which resides in home module

Below are my graphs

Main graph

<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/staging_nav_graph"
app:startDestination="@id/splashFragment2">

<fragment
    android:id="@+id/splashFragment2"
    android:name="splash.SplashFragment"
    android:label="fragment_splash"
    tools:layout="@layout/fragment_splash" >
    <action
        android:id="@+id/action_open_login"
        app:destination="@id/staging_authentication_nav_graph"
        app:popUpTo="@+id/staging_nav_graph"
        app:popUpToInclusive="true"/>
</fragment>

<include app:graph="@navigation/staging_authentication_nav_graph" />
<include app:graph="@navigation/staging_home_nav_graph" />
</navigation>

Authentication module graph

<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/staging_authentication_nav_graph"
app:startDestination="@id/loginFragment">

<fragment
    android:id="@+id/loginFragment"
    android:name="com.ocatave.featureauthentication.LoginFragment"
    android:label="login_fragment"
    tools:layout="@layout/login_fragment">
</fragment>
</navigation>

This is the home graph

<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/staging_home_nav_graph"
app:startDestination="@id/homeFragment">

<fragment
    android:id="@+id/homeFragment"
    android:name="com.octave.home.HomeFragment"
    android:label="home_fragment"
    tools:layout="@layout/home_fragment" />

</navigation>

How can I navigate to homeFragment from loginfragment?

1 Answer 1

2

I was able to do it with the help deeplink

in navigation graph

<fragment
    android:id="@+id/homeFragment"
    android:name="com.octave.home.HomeFragment"
    android:label="HomeFragment" >
    <deepLink app:uri="octave://home"/>
</fragment>

And the navigation code

findNavController().navigate(Uri.parse("octave://home"))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.