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

  • Post author:
  • Post category:World Tech

Development issue/problem:

I know there are a few questions here that ask if it is possible to add icons to an Android application, and they all end up answering NO……

But somehow the latest Facebook beta for Android seems to be doing something at least like an icon, even though technically it’s not true.

In this article a commentator says it has something to do with TouchWiz.
And also mentioned here as a feature of the S3 TouchWiz Jelly Bean addon.

I would still like to know how this is possible and if there is an API I can use in my own application (if it works in the right environment – i.e. on the same device where FB has this behavior)?

How can I solve this problem?

Solution 1:

Hey, you can use that freedom.

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


Add to that:

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


ShortcutBadger.applyTelling(context, 0) ;

Solution 2:

I figured out how to do this for Sony cameras.

I blogged about it here. I also published a separate question on this subject here.

Sony devices use a class called BadgeReciever.

  1. Explain com.sonyericsson.home.permission.BROADCAST_BADGE in the manifest file :
  2. Send your intention to the Badge Receiver :

Purpose = new purpose;

intent.setAction(com.sonyericsson.home.action.UPDATE_BADGE);intent.putExtra(com.sonyericsson.home.intent.extra.badge.ACTIVITY_NAME, com.yourrdomain.yourapp.MainActivity);int.putExtra(com.sonyericsson.home.sonyericsson.impact);intent.putExtra(com.sonyericsson.home.intent.extra.badge.SHOW_MESSAGE, where);intent.putExtra(com.sonyericsson.home.intent.extra.badge.MESSAGE, 99);intent.putExtra(, com.yourrdomain.yourapp)

sendBroadcast(intention) ;

  1. It’s done. Once this intention has been sent, the launcher must show a request icon.
  2. To delete the symbol again, simply send a new transmission, this time with SHOW_MESSAGE set to false :

intent.putExtra(com.sonyericsson.home.intent.extra.badge.SHOW_MESSAGE, fake) ;

I left out the details of how I found this, but it’s all available on the blog. It might be interesting for someone to read.

Solution 3:

There is no standard method to achieve this; many manufacturers, such as Sony or Samsung, have implemented this method in their own Android settings.

For example, in Samsung, you must intent with the action BADGE_COUNT_UPDATE, leave MainActivity your main activity class, and count the number you want to display in the icon of your application, note that 0 hides the icon :

Intent = new Intent(android.intent.action.BADGE_COUNT_UPDATE) ;
int.putExtra(badge_count, count) ;
int.putExtra(badge_count_package_name, context.getPackageName()) ;
int.putExtra(badge_count_class_name, MainActivity.class.getName()) ;
context.sendBroadcast(intention) ;

Sony devices use com.sonyericsson.home.action.UPDATE_BADGE with their custom add-ons, as @Marcus responded. So you need to add com.sonyericsson.home.permission.BROADCAST_BADGE to your application manifest, etc. :

Intention = new intention (com.sonyericsson.home.action.UPDATE_BADGE);
intention.putExtra(com.sonyericsson.home.intention.extra.badge.ACTIVITY_NAME, MainActivity.class.getName());
intention.putExtra(com.sonyericsson.home.intention.extra.badge.home.intention.extra.badge.SHOW_MESSAGE, where);
int.putExtra(com.sonyericsson.home.intent.extra.badge.MESSAGE, String.value.Of(count));
int.putExtra(com.sonyericsson.home.intent.extra.badge.PACKAGE_NAME, context.getPackageName());
context.sendBroadcast(intention) ;

Pay attention: It is advisable to query your application data (context.getPackageName(), MainActivity.class.getName()) instead of hardcoding them in case you rebuild them in the future.

Solution 4:

But the latest beta version of Android for Facebook is…..

Not according to the forum thread that contains the screenshot you linked. To quote Wakamu94 :

In fact, it’s TouchWiz, not just an application. I have a Galaxy S II that works with JellyBean 4.1.2 and does the same, but with different applications.

I can’t say if Samsung has a public API that allows applications to publish numbers that can be used as badges. It could be something they did privately with various companies.

We invite you to prove that you see these icons on a standard Android home screen, for example. For example, on a Nexus series device.

Good luck!

Related Tags:

notification number,android 10 app icon badges,how to keep app icon badges on android,change notification dot to number,icon with number android,android notification badge count not showing,android push notification badge count,how to add notification count in android,how to get badge count in android,notification count on icon | android programmatically,gmail badge notification android