4

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:

enter image description here

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:

Due to this scenario, my question is: the NavDeepLinkBuilder is the proper way to open my HomeFragment from the Service?

Thanks!

rsicarelli
  • 911
  • 1
  • 9
  • 26

0 Answers0