Search code examples
androidandroid-fragmentsdeep-linkingandroid-jetpackandroid-architecture-navigation

Jet pack navigation component get deep links programmatically


I am using the Navigation Component in my app. I have created the graph successfully and linked it with a bottom navigation bar. I have also added deep links to my fragments to which i can redirect successfully. My question is, if it is possible to get the declared deep links of a fragment in the graph programmatically. The reason i want to do so is to check if that fragment is already visible in the screen before loading it again through the deep link


Solution

  • Found a solution.

    val isCurrentFragmentWithDeepLink = navController.currentDestination?.hasDeepLink(uri) ?: false
    

    I am checking if the current fragment destination has that deep link or no. So assuming that the deep links are unique for each fragment i am not re navigating to it