ShortcutBadger
项目地址:leolin310148/ShortcutBadger
简介:An Android library supports badge notification like iOS in Samsung, LG, Sony and HTC launchers.
标签:
The ShortcutBadger makes your Android App show the count of unread messages as a badge on your App shortcut!
Supported launchers:
Sony | Samsung | LG | HTC |
Xiaomi | ASUS | ADW | APEX |
NOVA | Huawei(Not Fully Support) (1.1.7+) | ZUK(1.1.10+) | OPPO(Not Fully Support) (1.1.10+) |
EverythingMe | ZTE(1.1.17+) | KISS(1.1.18+) | |
LaunchTime |
- Nova launcher with TeslaUnread, Apex launcher, ADW Launcher provided by notz
- Solid launcher provided by MajeurAndroid
- KISS Launcher provided by alexander255
About Xiaomi devices
Xiaomi devices require extra setup with notifications, please read wiki.
IsBadgeWorking?
A tool for displaying your device, launcher & android version and testing whether ShortcutBadger works or not may be downloaded from
- Google Play https://play.google.com/store/apps/details?id=me.leolin.isbadgeworking
- The GitHub repository https://github.com/leolin310148/IsBadgeWorking.Android/releases
USAGE
1. Add mavenCentral to your build script.
repositories {
mavenCentral()
}
2. Add dependencies for ShortcutBadger, it's available from maven now.
dependencies {
compile "me.leolin:ShortcutBadger:1.1.22@aar"
}
3. Add the codes below:
int badgeCount = 1;
ShortcutBadger.applyCount(context, badgeCount); //for 1.1.4+
ShortcutBadger.with(getApplicationContext()).count(badgeCount); //for 1.1.3
4. If you want to remove the badge
ShortcutBadger.removeCount(context); //for 1.1.4+
ShortcutBadger.with(getApplicationContext()).remove(); //for 1.1.3
or
ShortcutBadger.applyCount(context, 0); //for 1.1.4+
ShortcutBadger.with(getApplicationContext()).count(0); //for 1.1.3