I would like to improve my code with function: -> after clicking a notification it goes to direct fragment
I basically use navigation component to navigate through fragments. As well it is able to go to the first page on my activity after clicking a notification, only when My application is closed from the background. Application is one activity with many fragments.
When my application is on some other fragments it crashes.
java.lang.IllegalArgumentException: Navigation destination com.example.program:id/action_global_MyGoalFragment cannot be found in the navigation graph NavGraph(com.example.program:id/nav_main_graph) startDestination={NavDestination(com.example.program:id/MyGoalFragment) label=MyGoalFragment}
That's my code:
val pendingIntent2 = NavDeepLinkBuilder(applicationContext)
.setComponentName(MainActivity::class.java)
.setGraph(R.navigation.nav_main_graph)
.setDestination(R.id.action_global_MyGoalFragment)
.createPendingIntent()
EDIT: I have found the method that someone used.. I understand that setArguments(bundle) could be used to send some data from fragment to another, like position of the list etc.
NavDeepLinkBuilder pending intent dosent work when app in background
Do you know how to solve my issue?