Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 364
Aju Avatar asked Aug 26 '11 10:08

Aju


People also ask

How do you handle multiple notifications?

Set the unique id to let Notification Manager knows this is a another notification instead of same notification. If you use the same unique Id for each notification, the Notification Manager will assume that is same notification and would replace the previous notification.

How do you count notifications?

Notification Counter basically counts the notifications that you got through an application and shows on the top of your application icon so that you get to know you get new messages or any new update without opening your application or specific feature like the message button in Instagram.

How do I manage multiple notifications on Android?

Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main.


2 Answers

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

like image 186
Pratik Avatar answered Nov 15 '22 01:11

Pratik


Are you looking for Notification#number?

like image 39
Felix Avatar answered Nov 14 '22 23:11

Felix