https://kotlinlang.org logo
#android
Title
# android
j

Joao Birk

10/22/2020, 5:10 PM
Hi there, quick question about NavDeepLinkBuilder. I'm using the https://github.com/matthewzhang007/android-architecture-components/blob/master/NavigationAdvancedSample/app/src/main/java/com/example/android/navigationadvancedsample/NavigationExtensions.kt to have a nav graph per tab. Each navigation_xxx.xml tab has the following snipped at the beginning.
Copy code
<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/home"
    app:startDestination="@id/home_tab">
All the
<deeplinks>
are defined in the first navigation_home.xml tab and in the AndroidManifes.xml I have 
<nav-graph android:value="@navigation/navigation_home"/>
When I build a pendingIntent I do the following:
Copy code
NavDeepLinkBuilder(context)
    .setGraph(R.navigation.navigation_home)
    .setDestination(<http://R.id.xxx|R.id.xxx>)
    .setArguments(...)
    .setComponentName(MainActivity::class.java)
    .createPendingIntent()
When I trigger such event I get the following message in the stack:
NavController: Could not find destination xxx:id/home in the navigation graph, ignoring the deep link from Intent
But it does work...it shows the correct page, issue is that the 
startDestination
 fragment gets instantiated TWICE. If I use the regular
TaskStackBuilder.create(context)
it works without a problem. Any hints? Thank you
3 Views