How to give counter if more than one Notifications are there
Asked Answered
S

4

7

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.

Spiritualism answered 26/8, 2011 at 10:45 Comment(0)
L
6

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

Lyda answered 26/8, 2011 at 11:9 Comment(1)
just a clarification as it took me a bit to find how to get it right. You need to change this, and then call back NotificationManager.notify with the same ID as the previous notification.Floor
E
2

Are you looking for Notification#number?

Encomiast answered 26/8, 2011 at 10:48 Comment(1)
I meant the public member named number in the Notification class, to which I also linked.Encomiast
B
0
NotificationManager notificationManager =(NotificationManager)context.getSystemService(NOTIFICATION_SERVICE);
notification.setNumber(1);
Blend answered 29/9, 2016 at 20:23 Comment(1)
While this may be the answer it is better to include how and why the code helps to solve the problem stated in the question.Worldling
B
0
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);
Blend answered 30/9, 2016 at 19:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.