0

I've read https://inthecheesefactory.com/blog/understand-android-activity-launchmode/en but various issues stop me from using non-default launch modes.

I have a notification with a pending intent.

I want this intent to not launch an activity, if the app already has a task. Instead when the user clicks on the notification I want the already running task to be brought on screen, without closing any of the task's activities. None of the app's activities should be closed or reordered when the task is brought to the front.

How can I achieve this?

fadedbee
  • 42,671
  • 44
  • 178
  • 308

1 Answers1

0

Just do what Android does when it launches an app from the HOME screen.

Use a "launch Intent" in your Notification:

Intent intent = getPackageManager().
    getLaunchIntentForPackage("my.package.name");

If your app is already running, this will bring the app to the foreground without creating any new components. If the app is NOT already running, this will start the app by launching the root Activity.

David Wasser
  • 93,459
  • 16
  • 209
  • 274