简体   繁体   中英

Android - how to add a badge count to an application icon?

how to add badge count on app icon on homescreen , like inbuilt gmail app, facebook app. I can run with Samsung and Sony devices. But others like Motorola , Micromax, HTC , LG does not sets Badge.

So how to set badge count for all android devices?

It is currently not possible to target "all android devices", only for some.

Certain manufacturers (eg Samsung notably) have included this functionality into their customised Android launchers. Also some 3rd-party launchers (eg Nova Launcher) have included an API to accomplish this.

Stock Android does not offer this functionality at the moment on the standard launcher.


I have just seen that this is a duplicate of:

There are many other related posts about this type of thing:

You can find more information there.

You can use library that bring you this ability.

ShortcutBadger is one on them that support many launchers.

For use this library you can add it to your gradle build dependency like this:

dependencies {
    compile 'me.leolin:ShortcutBadger:1.1.4@aar'
}

And add Badge like this:

ShortcutBadger.applyCount(context, badgeCount);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM