Multiple notifications with one status bar icon in android

I am using a custom notification ... how can I set a notification notification? and list this notice? this is my code ...

public void onReceive(Context context, Intent intent) { Toast.makeText(context, "coming", Toast.LENGTH_LONG).show(); Bundle descBundle = intent.getExtras(); CharSequence desc = descBundle.getString("description"); int reminderId = descBundle.getInt("reminderId"); NotificationManager mNotificationManager; mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); PendingIntent contentIntent = PendingIntent.getActivity(context, reminderId, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT); RemoteViews contentView = new RemoteViews(context.getPackageName(), R.layout.main); contentView.setImageViewResource(R.id.image, R.drawable.reminder_1); contentView.setTextViewText(R.id.text, desc); Notification notifyDetails = new Notification(); notifyDetails.icon = R.drawable.reminder_1; notifyDetails.when = System.currentTimeMillis(); notifyDetails.tickerText = desc; notifyDetails.iconLevel = 1; notifyDetails.number = reminderId; notifyDetails.contentView = contentView; notifyDetails.contentIntent = contentIntent; mNotificationManager.notify(0, notifyDetails); } 

I use this code to show a notification ... but it shows only one notification content ... but the icon does not show a notification ...

+7
android notifications
source share
2 answers

Remember that if you want to show several notifications for different objects, you need to assign a different notification identifier for each of them.

For example, if you have two different objects, you should call

 mNotificationManager.notify(0, notifyDetails); 

and

 mNotificationManager.notify(1, notifyDetails); 

If you do not, the notification will always be one and will be constantly updated.

+3
source share

Each icon corresponds to one notification; You cannot associate multiple notifications with one instance of an item in the notification panel.

You can, however, overlay a number on top of your icon (for example, show the number of events that are displayed by the icon), as some SMS and email applications do.

This is accomplished using the instance variable number for Notification , as shown in the code snippet above.

Edit:
To be more clear: if you need several notifications, you need to create several Notification objects and call NotificationManager.notify() several times.

Each Notification can only create one icon, can have one piece of content inside the notification area, and can have one Intent associated with it.

+2
source share

All Articles