How does Facebook add badge numbers on app icon in Android?

epeleg picture epeleg · Jul 7, 2013 · Viewed 52.4k times · Source

I know there are several Qs here that ask if its possible to add badges to an android app and they all end up with a NO answer...

But somehow the latest Facebook beta version for Android seems to do something which at least look like a badge even if it is not technically exactly that.

In that post one of the commenters says that it is somehow related to TouchWiz. And also here they mention it as a feature of the "S3 TouchWiz Jelly Bean Addon".

I still would appreciate information on how does this can be done and if there is some API for this that I can use in my own app (when running in an appropriate environment - i.e. the same device where FB demonstrates this behavior) ?

Answer

Ahmad Aghazadeh picture Ahmad Aghazadeh · Dec 3, 2016

Hi you can use this lib simply.

Support : Sony,Samsung,LG,HTC,Xiaomi,ASUS,ADW,APEX,NOVA,Huawei,ZUK,OPPO

ShortcutBadger

enter image description here

Add :

int badgeCount = 1;
ShortcutBadger.applyCount(context, badgeCount);  

Remove :

ShortcutBadger.applyCount(context, 0);