i am using custom notification...how can i set no of notification is showing?and list out those notification? 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 am using this code to show the notification...but it shows only one notification content...but icon shows no of notification...
Remember that if you want show multiple notify for different objects, you have to assign a different Notification ID for each one.
For example, if you have 2 different objects, you have to call
mNotificationManager.notify(0, notifyDetails);
and
mNotificationManager.notify(1, notifyDetails);
If you don't do that, Notification will be always one and will be always updated.
Each icon corresponds to one notification; you cannot associate multiple notifications with one instance of an item on the notification bar.
You can, however, overlay a number on top of your icon (e.g. to show the number of events that icon represents) like some SMS and email applications do.
This is done with the number
instance variable of Notification
, as you have in your code snippet above.
Edit:
To be more clear: If you want multiple notifications, you need to create multiple Notification
objects and call NotificationManager.notify()
multiple times.
Each Notification
can only produce one icon, can have one piece of content inside the notification area, and can have one Intent
associated with it.
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