Helper library to set android app icon badge count for different phone brand.
Forked from leolin310148/ShortcutBadger which seems no longer maintained.
- Add jitpack to your build script.
repositories { maven { url 'https://jitpack.io' } }
- Add dependencies for ShortcutBadgerX.
dependencies { implementation 'com.github.rlgo:ShortcutBadgerX:1.2.1' }
- Add the codes below:
int badgeCount = 1; Notification.Builder builder = new Notification.Builder(getApplicationContext()) .setContentTitle("ShortcutBadgerX") .setContentText("testing") .setNumber(badgeCount) .setSmallIcon(R.drawable.ic_launcher); Notification notification = builder.build(); ShortcutBadger.applyNotification(getApplicationContext(), notification, badgeCount); notificationManager.notify(notificationId, notification); ShortcutBadger.applyCount(getApplicationContext(), badgeCount);