19

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?

notification icon

Nuwan Alawatta
  • 1,812
  • 21
  • 29
theUturn
  • 1,101
  • 2
  • 12
  • 25
  • 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 Answers3

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:

And some libraries that might be helpful:

and more...

Community
  • 1
  • 1
BooDoo
  • 625
  • 5
  • 16
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

ShortcutBadger

Hamza Rahman
  • 664
  • 7
  • 19
0

In Flutter can be used library: Flutter App Badger

K.Amanov
  • 1,278
  • 14
  • 23