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".
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?
If you wanna resume from where you pause, then remove flag "NEW_TASK". It will not make new task. Hope you find it helpful in your task.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With