Reputation: 994
in my app I'm creating 3 notifications (with id 0,1, 2) depending on some data.
I use
setCancel(true);
on the notification in order to let the system cancel it on user click. I would like to cancell all the notifications (id 0,1,2) on the userclick on one of them. Is this possible?
This is my code about notification creation:
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Intent notificationIntent = new Intent(context, ActivityMain.class);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
Notification.Builder builder = new Notification.Builder(context);
Notification notification = null;
builder.setContentTitle(title)
.setContentIntent(contentIntent);
notification = new Notification.BigTextStyle(builder).bigText(mex).build();
notificationManager.notify(id, notification);
Upvotes: 1
Views: 161
Reputation: 13321
You can use NotificationManager.cancel(int id) to cancel your notifications when handling the Intent
from any of the notifications.
Upvotes: 0