How to open fragment page, when pressed a notification in android

If you are using Navigation Component you can open a specific destination using NavDeepLinkBuilder:


val pendingIntent = NavDeepLinkBuilder(context)
                     .setComponentName(MainActivity::class.java)
                     .setGraph(R.navigation.nav_graph)
                     .setDestination(R.id.destination)
                     .setArguments(bundle)
                     .createPendingIntent()

...

notificationBuilder.setContentIntent(pendingIntent)

...

Please note that it’s important to use setComponentName only if your destination isn’t in the launcher activity.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)