Создаётся и выводится на экран уведомление, при нажатии на которое запускается activity NotificationActivity (код немного упростил).
Intent notificationIntent = new Intent(context, NotificationActivity.class);
notificationIntent.putExtra("key_text", "notification text");
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
Notification.Builder builder = new Notification.Builder(context);
builder.setContentIntent(contentIntent)
.setSmallIcon(smallIconId)
.setLargeIcon(BitmapFactory.decodeResource(res, bigIconId))
.setTicker(res.getString(R.string.warning))
.setWhen(System.currentTimeMillis())
.setAutoCancel(true)
.setContentText(message);
Notification notification = builder.build();
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(NOTIFY_ID, notification);
Проблема в том, что при этом запускается и основная activity приложения MainActivity.
Как сделать так, чтобы запускалась только NotificationActivity при нажатии на уведомление?