Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Badge number on launcher icon for all mobile manufacturer

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.

like image 300
Sujay U N Avatar asked Nov 12 '17 14:11

Sujay U N


1 Answers

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.

like image 117
Ivan Wooll Avatar answered Oct 05 '22 21:10

Ivan Wooll