I want to show unread notification count on my app icon when app is not opened. this post seems to be close but it is 3 years old. Has there been any change on this or I should go with solutions provided in the accepted answer?
Asked
Active
Viewed 3.6k times
19
-
first you should store noftifications in local local storage(shared preference or db) and pass to viewbadger. when user open the app you should be delete noftifications and clear viewbadger. follow this example of code stackoverflow. https://github.com/jgilfelt/android-viewbadger – Muhammad Waleed May 22 '16 at 13:09
-
nothing close ui widgets... this is only question... on stack overflow tag.... :( – Muhammad Waleed May 22 '16 at 13:10
3 Answers
19
Unfortunately you cant achieve this for all android devices.
Certain manufacturers (e.g. Samsung or Sony) 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.
Some related posts for more information:
- 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
And some libraries that might be helpful:
and more...
-
3OM$G I can't believe Android have not created a native way to do it – MiguelHincapieC Jan 20 '17 at 00:06
2
I have found a solution But it work in some devices like samsung , Huawei..
Like ADD Library
implementation "me.leolin:ShortcutBadger:1.1.21@aar"
ADD to Gradle file
repositories {
mavenCentral()
}
Finally Add this in MainActivity.java file for Check
int badgeCount = 16;
ShortcutBadger.applyCount(this, badgeCount); //for 1.1.4+
16 Notification will be visible on app icon
And this is it !!
For detail Click here

Hamza Rahman
- 664
- 7
- 19