Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Multiple Notification

I have developing an App where the user can create event and set notification for that very event. So I want to add multiple notification. I am using the following code.

final Notification notifyDetails = new Notification(R.drawable.icon, "Myapp",calendar.getTimeInMillis());
Context context = getApplicationContext();
Intent notifyIntent = new Intent(context, ViewDoughnut.class);
PendingIntent pendingIntent = PendingIntent.getActivity(ViewCal.this, 0, notifyIntent, android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
notifyDetails.setLatestEventInfo(context, contentTitle, contentText, pendingIntent);
notifyDetails.flags = Notification.FLAG_ONGOING_EVENT;
mNotificationManager.notify(SIMPLE_NOTFICATION_ID, notifyDetails);

When I add an event and creating a notification using the above code, it is working fine. But if I add another event, no new notification created, the old one is just updated. I want to add one more notification. How to do it? Moreover, I want to delete any specific notification if the user delete the event corresponding to it. How it is possible?

like image 735
dev_android Avatar asked Mar 08 '11 11:03

dev_android


1 Answers

I assume that SIMPLE_NOTIFICATION_ID is a constant? To have separate notifications you need to use a different ID for each one.

like image 193
Dan Dyer Avatar answered Sep 23 '22 03:09

Dan Dyer