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) ?
I have figured out how this is done for Sony devices.
I've blogged about it here. I've also posted a seperate SO question about this here.
Sony devices use a class named
BadgeReciever
.Declare the
com.sonyericsson.home.permission.BROADCAST_BADGE
permission in your manifest file:Broadcast an
Intent
to theBadgeReceiver
:Done. Once this
Intent
is broadcast the launcher should show a badge on your application icon.To remove the badge again, simply send a new broadcast, this time with
SHOW_MESSAGE
set to false:I've excluded details on how I found this to keep the answer short, but it's all available in the blog. Might be an interesting read for someone.
Hi you can use this lib simply.
Support : Sony,Samsung,LG,HTC,Xiaomi,ASUS,ADW,APEX,NOVA,Huawei,ZUK,OPPO
ShortcutBadger
Add :
Remove :
Not according to the forum thread that contains the screenshot that you linked to. Quoting vakama94:
Whether Samsung has a public API to allow apps to publish numbers to be used as badges, I cannot say. This could be something that they did privately with a few firms.
You are welcome to provide evidence of seeing these badges on a stock Android home screen, such as one of the Nexus series devices.
There is not a standard way to achieve this; Many makers such as Sony or Samsung have implemented it in their own Android customization.
For example in Samsung, you have to broadcast an intent with BADGE_COUNT_UPDATE action, let
MainActivity
be your main activity class andcount
be the number you want to display in your app icon, note that 0 will hide the badge:Sony devices uses
"com.sonyericsson.home.action.UPDATE_BADGE"
action with their custom extras as @Marcus Answered, so you have to add"com.sonyericsson.home.permission.BROADCAST_BADGE"
permission to your app manifest and:Note: it's desirable to query your app's data (
context.getPackageName()
,MainActivity.class.getName()
) rather than hardcode it just in case you do some refactoring in the future.