I have a NavigationView (Drawer) with 5 menus each pointing to 5 different fragments. Say Fragment A,B,C,D,E.
Now I want to navigate to fragment C on clicking a notification (Pending Intent)
This is my deepLink
return NavDeepLinkBuilder(this)
.setComponentName(MainActivity::class.java)
.setGraph(R.navigation.mobile_navigation)
.setDestination(R.id.nav_fragment_c)
.setArguments(args)
.createPendingIntent()
It navigates to the fragment but suppose the user is currently on fragment A, the deep link adds the fragment on top of fragment A and won't let the user navigate back to fragment A even on clicking the drawer menu A (behaves like it's disabled). However, on clicking the back button it takes the user back to fragment A and everything works fine again (I guess it pops the fragment).
Am I doing something wrong here? How do I tell the navController to navigate to the desired fragment without adding it on top of whichever fragment the user is currently on.
Also noticed the same behavior when I do navController.navigate(destinationId)
Here is my navContoller
val navController = findNavController(R.id.nav_host_fragment_content_main)
binding.navView?.let {
appBarConfiguration = AppBarConfiguration(
setOf(
R.id.nav_fragment_a,
R.id.nav_fragment_b,
R.id.nav_fragment_c,
R.id.nav_fragment_d,
R.id.nav_fragment_e,
),
binding.drawerLayout
)
setupActionBarWithNavController(navController, appBarConfiguration)
it.setupWithNavController(navController)
}