Access the Bundle from navDeepLinkBuilder.setArguments(bundle)

There is a Service that at some point creates a Notification that always leads to the same Fragment. The Service wants to send the Fragment some Key-Value Data. In an Intent I would put those as Extras. The PendingIntent doesn’t have a putExtras method, but the NavDeepLinkBuilder has a setArguments method that takes a Bundle.

val pendingIntent = NavDeepLinkBuilder(applicationContext)

val builder = NotificationCompat.Builder(this, CHANNEL_ID)
            .setContentText("some text")
            .setContentTitle("some text")


Can the bundle that was fed into setArguments be accessed later from the destination Fragment? I tried it in the following way, but it just returns me the default value:

activity?.intent?.extras?.let {
    val myExtra = extras.getInt(KEY, DEFAULT_VALUE)
    Timber.e("got the Value $myExtra")

>Solution :

Yes, you can access your bundle from your destination fragment. Check this out

//your fragment
override fun onCreateView(
    inflater: LayoutInflater, container: ViewGroup?,
    savedInstanceState: Bundle?
): View {
    super.onCreateView(inflater, container, savedInstanceState)

    if (arguments != null) {
        if (requireArguments().containsKey(YOUR_KEY)) {

Leave a Reply