Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To avoid losing the bundle arguments during navigation while using setLaunchSingleTop(true), we can use the following approach:

  1. Create a new navigation action with the destination that has setLaunchSingleTop(true) set to true.

  2. Add the arguments to this new action instead of the original action.

  3. Override the onNewIntent(Intent) method in the activity that hosts the navigation component.

  4. Inside onNewIntent(Intent), get the arguments from the intent using getArguments() method and pass them to the navigate() method of the navigation controller.

  5. Finally, call the super.onNewIntent(Intent) method to ensure that the default behavior is not affected.