14

I need a badge counter on my application launcher icon.

I know the solution to get Badge counter inside the app, using TextView, But I need a solution to get the badge counter external to the app on the launcher icon.


In iOS we get the badge number count by

UIApplication.sharedApplication().applicationIconBadgeNumber

I am wondering why Android has not included anything like this with their SDK which every developer need.


Try 1 : Working only on sony mobiiles :

    Intent badgeIntent = new Intent();
    badgeIntent.setAction("com.sonyericsson.home.action.UPDATE_BADGE");
    badgeIntent.putExtra("com.sonyericsson.home.intent.extra.badge.PACKAGE_NAME", this.getPackageName());
    badgeIntent.putExtra("com.sonyericsson.home.intent.extra.badge.ACTIVITY_NAME", this.getClass().getName());
    badgeIntent.putExtra("com.sonyericsson.home.intent.extra.badge.SHOW_MESSAGE", ShwMsgBulVar);
    badgeIntent.putExtra("com.sonyericsson.home.intent.extra.badge.MESSAGE", "10");

     context.sendBroadcast(badgeIntent);

Try 2 : I tried the library : https://github.com/leolin310148/ShortcutBadger

It works only for few manufacturers and not common for all android mobiles.

ShortCutBadger is not working on OPPO, VIVO, Xiomi, Reliance LYF default launchers.

After couple of research, I came to know that, badge number depends on launcher manufacturer and listed as below :

ShortCutBadger Suported :

  • Samsung : "com.sec.android.app.launcher"
  • Sony : "com.sonyericsson.home"
  • HTC : "com.htc.launcher"
  • Asus : "com.asus.launcher"

ShortCutBadger not Suported :

  • Oppo :"com.oppo.launcher"
  • Xiomi : "com.miui.home"
  • Vivo : "com.bbk.launcher2"
  • Lyf : "com.android.launcher3"
  • Go Launcher : "com.gau.go.launcherex"

So is there any other general method which can work on all manufacturer mobiles?

Read so many posts and did lot of search but Many tell there is no such generic solution which is applicable for all launchers.
But I feel there is a solution because whatsapp and facebook app display the badge number in all the above mentioned launcher.

Sujay U N
  • 4,974
  • 11
  • 52
  • 88
  • 1
    https://dzone.com/articles/how-to-create-badges-item-counts-in-android can you go with this link – Amit Verma Nov 12 '17 at 15:20
  • 1
    Your Article explain to get badge counter inside the app. But I want external to the app. – Sujay U N Nov 14 '17 at 09:18
  • 5
    I dont know why they downvoted this and closed as off-topic, But im pretty 100% sure this is very important for developers facing the same exact issue. I could say to the people who are treating this as useless post, then if you ever have the same issue kindly dont look for this informative post. and thanks to @SujayUN wonderful explanation I finally understand how notification badge does and why it doesnt work with those certain phones. – david Dec 22 '17 at 18:14
  • 3
    Just want to point out my confusion, I still see facebook and whats app notification badge in those launchers you posted that isnt supported. – david Dec 22 '17 at 18:19

1 Answers1

10

There is no such function in Android as badge numbers are not a part of the platform. A few libraries exist that try to achieve this such as https://github.com/leolin310148/ShortcutBadger but you should understand that it does not work for every manufacturer's device. Also as far as I understand the badges only appear over the icon when it is on a home screen and not in the app drawer.

Ivan Wooll
  • 4,145
  • 3
  • 23
  • 34
  • 7
    Yes its true, but unlike facebook and whatsapp theyre currently showing the notification badge, How they have done this? – david Dec 22 '17 at 03:18
  • 2
    I checked on few devices, Even Whatsapp can't show badge on all the devices. – Darpan Aug 09 '18 at 08:31