In my use case, I have a Foreground Service bounded to a Notification.
The user can kill the app but the Foreground Service is still alive. Additionally, the user can click in the Notification and open the HomeFragment.
My current NavGraph looks like this:
Currently, I am using the NavDeepLinkBuilder to open my HomeFragment when the user clicks in the Notification:
val pendingIntent = NavDeepLinkBuilder(context)
.setGraph(R.navigation.nav_graph)
.setDestination(R.id.homeFragment)
.createPendingIntent()
return NotificationCompat.Builder()
.setOngoing(true)
.setContentIntent(pendingIntent)
.build()
This code works, but I am facing a few problems:
- On
onBackPressed, theHomeFragmentis "blinking" and I need to press the back button twice to actually close the app from theHomeFragment. - This approach doesn't look right since I have no deep links in my app;
The
NavDeepLinkBuilderdoes not accept anyAction(where I define thepopUpTo,popUpToInclusiveetc), only the destinationId
Due to this scenario, my question is: the NavDeepLinkBuilder is the proper way to open my HomeFragment from the Service?
Thanks!
