1. Are you ready for the Galaxy S20? Here is everything we know so far!

How to set the notification badge count programatically without sending notification?

Discussion in 'Android Development' started by buffoon, Nov 19, 2019.

  1. buffoon

    buffoon Lurker
    Thread Starter

    I want to change the notification badge count, say, whenever the user clicks on a button. At the moment, the only way I know to change the notification badge count is by sending a notification like so:

    Code (Java):
    1. Notification notification = new NotificationCompat.Builder(MainActivity.this, CHANNEL_ID)
    2.         .setContentTitle("New Messages")
    3.         .setContentText("You've received 3 new messages.")
    4.         .setSmallIcon(R.drawable.ic_notify_status)
    5.         .setNumber(messageCount)
    6.         .build();
    7.  
    I could technically send a notification every time the user presses the button, but that'd clutter the notification panel (as the goal here is to just change the badge count). So, is there anyway I can change the notification badge count without sending a notification?
     



    1. Download the Forums for Android™ app!


      Download

       
Loading...
Similar Threads - set notification badge
  1. Michael Culver
    Replies:
    2
    Views:
    133
  2. GiuseppeSM
    Replies:
    1
    Views:
    174
  3. icantchooseone
    Replies:
    2
    Views:
    218
  4. npuleio
    Replies:
    0
    Views:
    375
  5. halfbeing
    Replies:
    2
    Views:
    1,133
  6. JLSchutt
    Replies:
    1
    Views:
    4,069
  7. Petecc
    Replies:
    1
    Views:
    619
  8. ETtrailrunner
    Replies:
    10
    Views:
    10,261
  9. masplin
    Replies:
    10
    Views:
    4,609
  10. ETtrailrunner
    Replies:
    2
    Views:
    771

Share This Page

Loading...