How to show notification count on app icon like Facebook?

非 Y 不嫁゛ 提交于 2019-12-31 19:28:07

问题


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?


回答1:


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:

  • Samsung badger

  • ShortcutBadger

  • Badges

and more...




回答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



来源:https://stackoverflow.com/questions/37374002/how-to-show-notification-count-on-app-icon-like-facebook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!