Moin,
public void setMyAlarm() {
// Create an explicit intent for an Activity in your app
Intent intent1 = new Intent(this, MyReceiver.class);
intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
PendingIntent pendingIntent1 = PendingIntent.getActivity(this, 0, intent1, 0);
//Intent intent2 = new Intent(this, MyReceiver.class);
//intent2.setAction(Intent.ACTION_VIEW);
//PendingIntent pendingIntent2 = PendingIntent.getBroadcast(this, 0, intent2, 0);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, default_notification_channel_id);
builder.setContentTitle(derNameDerApp);
builder.setContentText(derText);
builder.setStyle(new NotificationCompat.BigTextStyle()
.bigText(derBigText));
builder.setSmallIcon(R.drawable.ic_launcher_foreground);
// Set the intent that will fire when the user taps the notification
builder.setContentIntent(pendingIntent1);
//builder.addAction(R.drawable.ic_launcher_foreground, "(+1)", pendingIntent2);
builder.setAutoCancel(true);
builder.setChannelId(NOTIFICATION_CHANNEL_ID);
Intent intent3 = new Intent(this, MyReceiver.class);
intent3.putExtra(MyReceiver.NOTIFICATION_ID, 1);
intent3.putExtra(MyReceiver.NOTIFICATION, builder.build());
PendingIntent pendingIntent3 = PendingIntent.getBroadcast(this, 0, intent3, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
assert alarmManager != null;
alarmManager.setExact(AlarmManager.RTC_WAKEUP, next, pendingIntent3);
}
die Notification funktioniert bereits! Aber wenn man A auf die Notification „tabbt“, soll
- sich die Notification schließen (funktioniert bereits),
- sich die App/MainActivity öffnen (funktioniert noch nicht),
B auf einen zusätzlichen Tab (+1) „tabbt“, soll - sich die Notification schließen (funktioniert bereits),
- sich die App/MainActivity öffnen (funktioniert noch nicht),
- eine Methode der App/MainActivity aufgerufen werden werden (funktioniert noch nicht).
(5.) ist ggfs. gar nicht möglich, da die MyReceiver.class
die App nicht kennt, aber ich weiß es nicht genau.