Android: Deep-link with Bottom navigation bar

Viewed 1826

I am trying to integrate a web deep link URL in my application using the android navigation component for that I have been doing the following.

The intended fragment XML which should be open by the URL.

<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/apk/res-auto"
    android:id="@+id/sample_navigation_graph"
    app:startDestination="@id/sampleFragment">

    <fragment
        android:id="@+id/sampleFragment"
        android:name=".ui.tab.sampleFragment"
        android:label="SampleFragment"
        tools:layout="@layout/fragment_new">
        <deepLink app:uri="https://example.com/sutirth" />
    </fragment>
</navigation>

My android manifest file declaration

<activity android:name=".MainActivity"
            android:windowSoftInputMode="stateHidden|adjustResize">
<intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data
                    android:scheme="https"
                    android:host="example.com"/>
            </intent-filter>
            <nav-graph android:value="@navigation/app"/>
        </activity>

My main navigation 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/app"
    app:startDestination="@id/sample_navigation_graph"
    tools:ignore="InvalidNavigation">


    <include app:graph="@navigation/sample_navigation_graph"/>


</navigation>

Using the above setup I am able to navigate to my destination perfectly. However, when its navigated via deep-link I am unable to see the bottom-navigation bar and toolbar. Is it intended to be this way?

Source Ref: Android code samples for bottom-navigation

1 Answers

If you are using a multi-module navigation graph. Be sure to add the particular navigation graph to the manifest as well. Your deep-link would work properly

For e.g android manifest

<activity android:name=".MainActivity"
            android:windowSoftInputMode="stateHidden|adjustResize">
<intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data
                    android:scheme="https"
                    android:host="example.com"/>
            </intent-filter>
            <nav-graph android:value="@navigation/app"/>
 <include app:graph="@navigation/sample_navigation_graph"/>
        </activity>
Related