Count Notification For Menu Item and Launcher Icon


Yes we can display Count Notification in action bar and launcher icon. Before creating Count Notification in launcher icon and action bar menu item we need to know some facts. First one is that the native method for creating Count Notification in android launcher icon is deprecated long time ago. The possible solution is to use phone manufactures or launcher application API’s. It’s very hard work, writing code for each manufactures and launcher applications including their API library files. This results in too bulky code, time lose and increase the size of the application. We can overcome these problems and difficulties by using ShortcutBadger Github . ShortcutBadger is a library that can do count notification in launcher icon irrespective of manufacture or launcher app if they support Count Notification. ShortcutBadger take care of converting our input into supported manufacture or launcher app Count Notification.

First add the dependency

dependencies {
compile 'me.leolin:ShortcutBadger:1.1.8'

Now we move on to code part

Just add
ShortcutBadger.applyCount(this, i);

I is the integer value set i=0 to disable the count. You can check more information in github.
Count Notification for menu item in actionbar.

1.Creating the icon

The icon must be a vector asset normal png or jpg won’t work. You can get free vector icons from flaticon .Here icon named ic_home is used, now create another xml file called ic_menu.xml to hold the ic_home file. To handle the count a class named Count is used it extents drawable. Set count using setCounting method set 0 to reset the count.


2.icon holder

Count Notification Menu Item and Launcher Icon logicchip 4
The xml file called ic_menu holds the changes for icon. One thing is to keep in mind is that the id f all icon holder must be same, otherwise you have to create more counter classes.



We created icon and icon holder now the counting part. Create a class name count then extent the class Drawable.Now we end up with a class file looks like this.

Change the getOpticity to this

Create objects.

Create a constructor.

Editing draw method.

Create another method setCount.

setCounting method.

The full code.


4.Creating the menu item

Modify the menu file located in menu folder in your project.Add this to the menu.

All the other items are below this.

5. Main class

A menu item object is created.Some screen shots.
Count Notification Menu Item and Launcher Icon logicchip 5Count Notification Menu Item and Launcher Icon logicchip 6Count Notification Menu Item and Launcher Icon logicchip 7









Now the first part is the



Now for the Ui part of Count Notification.


2 comments on “Count Notification For Menu Item and Launcher Icon

Leave a Reply

%d bloggers like this: