how to identify selected notification from multiple Notification android? -
here myfirebasemessagingservice using generate notification in application.
class myfirebasemessagingservice extends firebasemessagingservice { private final string tag = this.getclass().getsimplename(); @override public void onmessagereceived(remotemessage remotemessage) { //displaying data in log log.d(tag, "from: " + remotemessage.getfrom()); log.d(tag, "notification message body: " + remotemessage.getnotification().getbody()); log.d(tag, "onmessagereceived: " + remotemessage.getnotification().gettag()); //calling method generate notification sendnotification(remotemessage.getnotification().getbody(),remotemessage.getnotification().gettitle()); } //this method generating push notification //it same did in earlier posts private void sendnotification(string messagebody, string title) { intent intent = new intent(this, notificationdetailactivity.class); intent.putextra(appconstant.notification, messagebody); intent.putextra(appconstant.title, title); intent.addflags(intent.flag_activity_clear_top); pendingintent pendingintent = pendingintent.getactivity(this, 0, intent, pendingintent.flag_update_current); uri defaultsounduri = ringtonemanager.getdefaulturi(ringtonemanager.type_notification); notificationcompat.builder notificationbuilder = new notificationcompat.builder(this) .setsmallicon(r.mipmap.ic_launcher) .setcontenttitle(title) .setcontenttext(messagebody) .setautocancel(true) .setsound(defaultsounduri) .setcontentintent(pendingintent); notificationmanager notificationmanager = (notificationmanager) getsystemservice(context.notification_service); notificationmanager.notify((int) ((new date().gettime() / 1000l) % integer.max_value), notificationbuilder.build()); }
}
here able generate nultiple notification not able identify perticular notification multiple notification in notification bar, displaying latest notification's title , message body, guys please me.
notificationmanager.notify((int) ((new date().gettime() / 1000l) % integer.max_value), notificationbuilder.build());
replace (int) ((new date().gettime() / 1000l) % integer.max_value)
identification logic of own (e.g incremental integers).
Comments
Post a Comment