2

My application has two activities A and B. A is the root activity and set with singleTop launchMode. B is started from A, i.e. the task stack is (A->B) I add a status notification to launch the application as long press Home button. The notification intent point to activity A.

When the task stack is (A) only, the intent invokes onNewIntent() from existing A, as expected. When the task stack is (A->B), the intent create new activity A. But what I wants is resume task (A->B) as switch recent apps by long press Home button.

Is the problem caused by incorrect launch mode used? or any flags need to be added to the notification intent?

Thanks.

  • Read this post on how to handle launching activities from a notification: http://developer.android.com/guide/topics/ui/notifiers/notifications.html – bkurzius Jan 29 '13 at 19:28
  • possible duplicate of [Resume application and stack from notification](http://stackoverflow.com/questions/5502427/resume-application-and-stack-from-notification) – njzk2 Jan 07 '14 at 20:49

1 Answers1

1

You can use the following from your notification manager:

Intent intent = new Intent(context, ActivityA.class);
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
context.startActivity(intent);

Make sure that your ActivityA is not launched with FLAG_ACTIVITY_NEW_TASK.

peter
  • 1,034
  • 1
  • 9
  • 23