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

Joao Birk

06/02/2020, 7:13 PM
Hi there, question about navigation components and the use of: https://github.com/android/architecture-components-samples/blob/master/NavigationAdvancedSample/app/src/main/java/com/example/android/navigationadvancedsample/NavigationExtensions.kt I have a bottomNavigationView with 5 tabs (therefore 5 navigation graphs) and each tab has its own deep links. I'm having an issue with deep links where if I leave the app (put in on background) with the second tab selected, push an intent that deep links to the first tab, the app is open on the second tab and the linking doesn't happen. I have also added the following code:
Copy code
override fun onNewIntent(intent: Intent) {
    super.onNewIntent(intent)

    if (currentNavController?.value?.handleDeepLink(intent) == false) {
    ...
    }
}
I understand the problem, basically the
currentNavController.value
which has the
navigation_graph_2.xml
doesnt have such deep link set...how can I check if other graphs (tabs) support such deep link and then navigate to the desired tab?
i

Ian Lake

06/02/2020, 7:43 PM
You should stop using a
launchMode
on your activity, which would remove the need for
onNewIntent()
and NavigationExtensions would handle it for you, since it checks through every graph to find a matching deep link
j

Joao Birk

06/02/2020, 7:52 PM
Ha, right on! Thanks @Ian Lake.
6 Views