java - How to create multiple notification? -
this myreceiver.java class , here have written code display single notification. how create multiple notification here.
public class myreceiver extends broadcastreceiver{ string reqpopending; int mid=0; @override public void onreceive(context context, intent intent) { // todo auto-generated method stub long when = system.currenttimemillis(); notificationmanager notificationmanager = (notificationmanager) context .getsystemservice(context.notification_service); intent notificationintent = new intent(context, splashscreen.class); notificationintent.setflags(intent.flag_activity_clear_top); pendingintent pendingintent = pendingintent.getactivity(context, 0, notificationintent, pendingintent.flag_update_current); uri alarmsound = ringtonemanager.getdefaulturi(ringtonemanager.type_notification); notificationcompat.builder mnotifybuilder = new notificationcompat.builder( context).setsmallicon(r.drawable.dashboard) .setcontenttitle("dash board counts") .setcontenttext("p.o counts-532,198,654,255,901 zeroinward-303 partialinward-777").setsound(alarmsound) .setautocancel(true).setwhen(when) .setcontentintent(pendingintent) .setvibrate(new long[]{1000, 1000, 1000, 1000, 1000}); notificationmanager.notify(mid, mnotifybuilder.build()); mid++; }
please find below code being run in loop
public class myreceiver extends broadcastreceiver{ string reqpopending; int mid=0; @override public void onreceive(context context, intent intent) { // todo auto-generated method stub for(int = 0; < 3; i++) { long when = system.currenttimemillis(); notificationmanager notificationmanager = (notificationmanager) context .getsystemservice(context.notification_service); intent notificationintent = new intent(context, splashscreen.class); notificationintent.setflags(intent.flag_activity_clear_top); pendingintent pendingintent = pendingintent.getactivity(context, 0, notificationintent, pendingintent.flag_update_current); uri alarmsound = ringtonemanager.getdefaulturi(ringtonemanager.type_notification); notificationcompat.builder mnotifybuilder = new notificationcompat.builder( context).setsmallicon(r.drawable.dashboard) .setcontenttitle("dash board counts") .setcontenttext("p.o counts-532,198,654,255,901 zeroinward-303 partialinward-777").setsound(alarmsound) .setautocancel(true).setwhen(when) .setcontentintent(pendingintent) .setvibrate(new long[]{1000, 1000, 1000, 1000, 1000}); notificationmanager.notify((int)when, mnotifybuilder.build()); }
}
hope helps.
Comments
Post a Comment