カスタム Uri スキームでプッシュ通知を受け取りました:myapp://main
私のonReceive
私は通知を作成します:
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);
}
次にその通知をタップすると、MainActivity である新しいアクティビティが開きます。しかし、現在実行中のアプリを開くだけでなく、まったく新しいプロセスも作成するようです。
欠落しているフラグがいくつかありますか?