Android: After creating a new notification, the older one is replaced -



Android: After creating a new notification, the older one is replaced -

i want create notification without canceling/deleting previous notifications app. here code creating notification:

private void notification(context context, string title, string content) { notificationcompat.builder mbuilder = new notificationcompat.builder(context) .setsmallicon(r.drawable.notification_icon) .setcontenttitle(title) .setcontenttext(content); intent resultintent = new intent(context, mainactivity.class); taskstackbuilder stackbuilder = taskstackbuilder.create(context); // adds stack intent (but not intent itself) stackbuilder.addparentstack(mainactivity.class); // adds intent starts activity top of stack stackbuilder.addnextintent(resultintent); pendingintent resultpendingintent = stackbuilder.getpendingintent( 0, pendingintent.flag_update_current ); mbuilder.setcontentintent(resultpendingintent); notificationmanager mnotificationmanager = (notificationmanager) context.getsystemservice(context.notification_service); //id allows update notification later on. mnotificationmanager.notify(100, mbuilder.build()); }

you using hardcoded id notification, of course of study replace old one. seek using variable id instead of hardcoded 100.

mnotificationmanager.notify(100+x, mbuilder.build());

or of sort.

android notifications notify

Comments