Aju
Aju

Reputation: 4599

How to give counter if more than one Notifications are there

I have implemented PushNotification Using C2dm. I am getting notification from c2dm also. My problem is I want to give a counter when I get more than one notifications, I mean like "You have a Notification(count)". How can I implement this.

Upvotes: 7

Views: 15470

Answers (4)

Farruh Habibullaev
Farruh Habibullaev

Reputation: 2392

NotificationManager notificationManager=(NotificationManager)context.getSystemService(NOTIFICATION_SERVICE);

This creates the notificationManager class instance. Then you will have notification object with which you can do any adjustment. To set the number of the messages you have received, simply set this:

notification.setNumber(1);

Upvotes: 0

Farruh Habibullaev
Farruh Habibullaev

Reputation: 2392

NotificationManager notificationManager =(NotificationManager)context.getSystemService(NOTIFICATION_SERVICE);
notification.setNumber(1);

Upvotes: 0

Pratik
Pratik

Reputation: 30855

you can do to set the number value into the Notification object

Notification notifyDetails = new Notification(R.drawable.alarm,intent.getExtras().getString(KEY_TITLE),System.currentTimeMillis());
notifyDetails.number = 1; ////// here you can pass the counter value which will so you the number 

here is the link

http://developer.android.com/reference/android/app/Notification.html#number

http://developer.android.com/guide/topics/ui/notifiers/notifications.html

Android Notification Bar Number

Upvotes: 6

Felix
Felix

Reputation: 89566

Are you looking for Notification#number?

Upvotes: 2

Related Questions