I am making an app based on notification in which I had implemented Notification code but in that code I want to about notification Id .what is that can any body explain me .
code:-
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);
mBuilder.setContentTitle("This is a notification");
mBuilder.setSmallIcon(R.drawable.app_me);
mBuilder.setContentText("You have successfully created notification");
Intent resultIntent = new Intent(this,ResultActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addParentStack(ResultActivity.class);
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPending = stackBuilder.getPendingIntent(0,PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(resultPending);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
// notificationID allows you to update the notification later on.
notificationManager.notify(notificationID, mBuilder.build());
When you need to issue a notification multiple times for the same type of event, you should avoid making a completely new notification. Instead, you should consider updating a previous notification. For that you need NotificationID. Notification can be updated, issue it with a notification ID by calling Check here, https://developer.android.com/training/notify-user/managing.html
Its a numeric id that you get to define. If you later want to change this notification, you can specify the same notification id and it will change the original notification (or cancel it if you want) rather than create a new one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With