Im receiving a push notification with a custom Uri scheme: myapp://main
In my onReceive
i create a notification:
public void createNotification(Context context, String title, String message, String summary, Uri uri) {
Notification.Builder notification = new Notification.Builder(context)
.setContentTitle(title)
.setContentText(message)
.setSmallIcon(R.drawable.ic_launcher)
.setDefaults(Notification.DEFAULT_LIGHTS)
.setAutoCancel(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && summary != null)
notification.setSubText(summary);
Intent intent = new Intent("android.intent.action.VIEW", uri);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
notification.setContentIntent(pendingIntent);
Notification noti;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
noti = notification.build();
else
noti = notification.getNotification();
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, noti);
}
When I then tap on that notification it opens a new Activity which is my MainActivity. But it seems like it creates a whole new process aswell instead of just opening my currently running app.
Are there some flags Im missing?
There are LaunchModes for Activity
android:launchMode=["multiple" | "singleTop" |"singleTask" | "singleInstance"]
Read more about LaunchMode here
This can be placed in your Activity tag in manifest
.
To get the intent data try onNewIntent()