6

I need to show badge on App icon in my application

what i have tried:

  1. This https://github.com/leolin310148/ShortcutBadger library do it on many devices.I have checked its manifest and saw that there exists a permission for each type of launcher

     <!--for Samsung-->
       <uses-permission      android:name="com.sec.android.provider.badge.permission.READ"/>
     <uses-permission android:name="com.sec.android.provider.badge.permission.WRITE"/>
    
     <!--for htc-->
    <uses-permission android:name="com.htc.launcher.permission.READ_SETTINGS"/>
     <uses-permission android:name="com.htc.launcher.permission.UPDATE_SHORTCUT"/>
    
      <!--for sony-->
     <uses-permission android:name="com.sonyericsson.home.permission.BROADCAST_BADGE"/>
     <uses-permission android:name="com.sonymobile.home.permission.PROVIDER_INSERT_BADGE"/>
    <!--for apex-->
    <uses-permission android:name="com.anddoes.launcher.permission.UPDATE_COUNT"/>
    
     <!--for solid-->
     <uses-permission android:name="com.majeur.launcher.permission.UPDATE_BADGE"/>
    
     <!--for huawei-->
     <uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE" />
     <uses-permission android:name="com.huawei.android.launcher.permission.READ_SETTINGS" />
     <uses-permission android:name="com.huawei.android.launcher.permission.WRITE_SETTINGS" />
    
     <!--for ZUK-->
     <uses-permission android:name="android.permission.READ_APP_BADGE"/>
    

2.I have gone through many available answers that are already on stackoverflow like

How to display count of notifications in app launcher icon

can we show badge number on android app icon like iphone?

How to show badge count with app icon on Redmi?

Add unread notification badge on android app icon

Is there a way to add a badge to an application icon in Android?

All these resources helped me to attain the task on above mentioned devices but i can still see there are lot man devices like xiomi,micromax etc in which app like wtsapp,facebook etc are showing badges but i am unable to show badge on these devices.

Have anyone here has achieved it.Any help will be appreciated.

Community
  • 1
  • 1
Harry Sharma
  • 2,190
  • 2
  • 15
  • 41
  • This definitely has something to do with permissions because on redmi you can go to settings->Apps->Manage apps->Your app->Notifications and switch on the "Show app icon badges". This will start showing the app icon badges..... – DragonFire Jan 16 '20 at 22:37

3 Answers3

1

This is not a feature the of Android system. Device manufacturers (like Xiaomi you mentioned) or launcher developers (like Nova Launcher) can implement it and expose an api for app developers, but there is no standard for that, nor is it expected by the users to be there.

In general, you should not try to do this on Android.

Kelevandos
  • 7,024
  • 2
  • 29
  • 46
  • 2
    Thanks for the answer.yes i know there is no standerd way but still apps like wtsapp ebay and facebook are doing this.so there will be definitely a workaround that these guys found.I am asking that. – Harry Sharma Oct 20 '16 at 08:20
  • They are not "doing this". The launcher you use may allow them to show such data, but this depends on the launcher and not on the app, for the most part. Google Now launcher will not show any badges on any devices, try it. – Kelevandos Oct 20 '16 at 08:21
  • Thanks.but still there will be a way like on micromax also i can see.Atlease permissions for these launchers will be mentioned somewhere.Like we already have permissions for launcher like samsung,huwai etc. – Harry Sharma Oct 20 '16 at 08:24
  • 2
    But how did the facebook and whatsapp show a notification badge to those certain phones ? – david Dec 22 '17 at 18:18
1

For displaying badge, Google may have stopped showing numbers count on App Icon as a badge but I think it's still showing a dot to let the user know there is something new to that app.

For more information you can go through this official link from Google : https://developer.android.com/training/notify-user/badges

0

You can! From the doc: https://developer.android.com/training/notify-user/badges

By default, each notification increments a number displayed, but you can override this number for your app. For example, this might be useful if you're using just one notification to represent multiple new messages but you want the count here to represent the number of total new messages.

To set a custom number, call setNumber() on the notification, as shown here:

var notification = NotificationCompat.Builder(this@MainActivity, CHANNEL_ID)
        .setContentTitle("New Messages")
        .setContentText("You've received 3 new messages.")
        .setSmallIcon(R.drawable.ic_notify_status)
        .setNumber(messageCount)
        .build()
G Clovs
  • 2,442
  • 3
  • 19
  • 24