android - Notifications being erased if I get a new one from myself -
i have below class gets called whenever receive push notification. (works wherever though). issue that, if send notification device mobile (lets iphone) getting notification , stays in notification bar. if not touch it, , send one, 1 arrive , 2 icons appear in notification bar, however, moment send notification own mobile myself, current notifications in bar disappear , replaced mine. when send new one, additional icon not appear, rather old 1 gets updated.
how can make each notification appear in notification bar ? (because each 1 has unique id sent via intent specific thing upon opening of designated activity)
private void sendnotification(string data, string id, context ctx) { mnotificationmanager = (notificationmanager) ctx.getsystemservice(context.notification_service); intent myintent = new intent(ctx, myactiviy.class); myintent.putextra("data", data); myintent.putextra("id", id); pendingintent contentintent = pendingintent.getactivity(ctx, 0, myintent, pendingintent.flag_update_current); notificationcompat.builder mbuilder = new notificationcompat.builder(ctx) .setsmallicon(r.drawable.ic_launcher) .setcontenttitle("notification") .setticker("notification") .setstyle(new notificationcompat.bigtextstyle().bigtext(data)) .setautocancel(false) .setcontenttext(data); mbuilder.setcontentintent(contentintent); mnotificationmanager.notify((int) (system.currenttimemillis()/1000), mbuilder.build()); }?
the procedure using show notification depreciated. use following give unique int mnotificationmanager.notify(uniqueid, mbuilder.build()
show seperate notifications.
private void generatenotification(context context, string message, string notificationid) { int notify = integer.valueof(notificationid); notificationmanager mnotificationmanager = (notificationmanager) context.getsystemservice(context.notification_service); intent resultintent = new intent(context, viewpost.class); bundle params = new bundle(); params.putstring("group_id", this.groupid.get(notificationid)); params.putstring("post_id", this.postid.get(notificationid)); params.putstring("notification", "notification"); resultintent.addflags(intent.flag_activity_new_task); resultintent.putextras(params); taskstackbuilder stackbuilder = taskstackbuilder.create(context); stackbuilder.addparentstack(viewpost.class); stackbuilder.addnextintent(resultintent); pendingintent resultpendingintent = stackbuilder.getpendingintent(notify, pendingintent.flag_cancel_current); notificationcompat.builder mbuilder = new notificationcompat.builder(context) .setsmallicon(r.drawable.icon) .setcontenttitle("fleegroups notification") .setstyle(new notificationcompat.bigtextstyle() .bigtext(message)) .setcontenttext(message) .setautocancel(true) .setdefaults(notification.default_all); mbuilder.setcontentintent(resultpendingintent); mnotificationmanager.notify(notify, mbuilder.build()); }
Comments
Post a Comment