12/08/2018, 17:27

ShortcutBadger

ShortcutBadger i an Android library supports badge notification like iOS in Android devices. The ShortcutBadger makes your Android App show the count of unread messages as a badge on your App shortcut. It can be easily implemented in the project by following the easy steps below 1) Add ...

ShortcutBadger i an Android library supports badge notification like iOS in Android devices. The ShortcutBadger makes your Android App show the count of unread messages as a badge on your App shortcut. It can be easily implemented in the project by following the easy steps below

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.21@aar"
}

3) Add the codes below:

int badgeCount = 1; //Number of notification to be displayed on your app icon 
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	

That's it!!! Its a easy as ABC to get your app icon notification counts on the display active. For more info please refer here..

0