I am writing an SDK to be used in hosting app. My SDK creates a notification that needs to resume the app, just the same way as you press on the tasks button and select the app, or long press on Home button and select your app.
Here is what I been trying to do:
PackageManager packageManager = context.getPackageManager();
intent = packageManager.getLaunchIntentForPackage(context.getPackageName());
intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 10, intent, flags);
Notification notification = new NotificationCompat.Builder(context).
setContentIntent(pendingIntent).
...
build();
getNotificationManager().notify(NOTIFICATION_ID, notification);
I been testing this on host app with one launcher activity with lunching mode "default"(no launching mode been set in the manifest) and my sdk also got 1 activity with lunch mode "singleTask".
- So I lunch the app
- Start my SDK activity it fires a test notification in onCreat method.
- I press home
- I click on the notification.
After doing those steps I expect to be returned to my activity but instead it opens another instance of the host launcher activity. What am I missing? How do I make this work?