Android - 如何向应用程序图标添加徽章计数?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25863506/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android - how to add a badge count to an application icon?
提问by user2231294
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.
如何在主屏幕上的应用程序图标上添加徽章计数,例如内置的 Gmail 应用程序、Facebook 应用程序。我可以使用三星和索尼设备运行。但其他如摩托罗拉、Micromax、HTC、LG 不设置徽章。
So how to set badge count for all android devices?
那么如何为所有安卓设备设置徽章计数呢?
回答by Richard Le Mesurier
It is currently not possible to target "all android devices", only for some.
目前无法针对“所有 android 设备”,只能针对某些。
Certain manufacturers (e.g. Samsung notably) have included this functionality into their customised Android launchers. Also some 3rd-party launchers (e.g. Nova Launcher) have included an API to accomplish this.
某些制造商(尤其是三星)已将此功能包含在其定制的 Android 启动器中。一些 3rd 方启动器(例如 Nova Launcher)也包含一个 API 来实现这一点。
Stock Android does not offer this functionality at the moment on the standard launcher.
Stock Android 目前在标准启动器上不提供此功能。
I have just seen that this is a duplicate of:
我刚刚看到这是一个重复的:
There are many other related posts about this type of thing:
关于这种类型的事情还有很多其他相关的帖子:
- How does Facebook add badge numbers on app icon in Android?
- https://stackoverflow.com/questions/18205569/does-samsung-modifies-its-android-roms-to-have-badges-on-email-and-sms-icons?rq=1
- adding notification badge on app icon in android
- How to interface with the BadgeProvider on Samsung phones to add a count to the app icon?
- How to add a notification badge/count to application icon on Sony Xperia devices?
- How to make application badge on android?
- How to display count of notifications in app launcher icon
- Facebook 如何在 Android 中的应用程序图标上添加徽章编号?
- https://stackoverflow.com/questions/18205569/does-samsung-modifying-its-android-roms-to-have-badges-on-email-and-sms-icons?rq=1
- 在android中的应用程序图标上添加通知徽章
- 如何与三星手机上的 BadgeProvider 接口以向应用程序图标添加计数?
- 如何在 Sony Xperia 设备上向应用程序图标添加通知标记/计数?
- 如何在android上制作应用程序徽章?
- 如何在应用启动器图标中显示通知计数
You can find more information there.
您可以在那里找到更多信息。
回答by Mohamad Khani
You can use library that bring you this ability.
您可以使用为您带来这种能力的库。
ShortcutBadgeris one on them that support many launchers.
ShortcutBadger就是其中之一,支持许多启动器。
For use this library you can add it to your gradle build dependency like this:
要使用此库,您可以将其添加到您的 gradle 构建依赖项中,如下所示:
dependencies {
compile 'me.leolin:ShortcutBadger:1.1.4@aar'
}
And add Badge like this:
并像这样添加徽章:
ShortcutBadger.applyCount(context, badgeCount);