0

I am creating an explicit deep link in navigation component using safe args.

PendingIntent pendingIntent = new NavDeepLinkBuilder(getApplicationContext())
                .setGraph(R.navigation.mobile_navigation)
                .setDestination(R.id.nav_order_details)
                .setArguments(//TODO pass bundle)
                .setComponentName(MainActivity.class)
                .createPendingIntent();

The problem is I need to pass a bundle in arguments but I dont know how to convert Safe args to bundle in java.

I found this format in kotlin

OrderDetailsFragmentArgs(id).toBundle()

I need to convert it into java code. Please help.

Ankit Verma
  • 496
  • 5
  • 21

1 Answers1

1

I finally solved it by using this code

Bundle bundle = new Bundle();
bundle.putString("orderId", id);

OrderDetailsFragmentArgs args = OrderDetailsFragmentArgs.fromBundle(bundle);

PendingIntent intent = new NavDeepLinkBuilder(getApplicationContext())
                    .setGraph(R.navigation.mobile_navigation)
                    .setDestination(R.id.nav_order_details)
                    .setArguments(args.toBundle())
                    .setComponentName(MainActivity.class)
                    .createPendingIntent();
Ankit Verma
  • 496
  • 5
  • 21