Welcome to StackOverflow.
It would appear the pacakge you're using is no longer maintained, as it's been deprecated in favour of AndroidX and I'd recommend migrating to that if it's an option for your project.
If I'm correct in my assumption, you're attempting to do something similar to what you can achieve on iOS, however the Android SDK does not support this out of the box, although there appears to be a workaround
As such, the function you're calling cannot be used for that particular purpose. The setNumber
function sets the number displayed in the long press menu
All this having been said
You CAN update a notification that's already been sent, and update the number shown in the long press menu using the setNumber
method, as detailed in this article
TL;DR:
Post the notification with an identifier using the following method and save the identifier somewhere for later: NotificationManagerCompat.notify(notificationId, builder.build());
Rerun the same code you posted in your question, updating the badge number in the process
Run NotificationManagerCompat.notify()
again, passing the SAME notification id and the NEW notification.
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
int notificationID = 123456;
int messageCount = 1;
Notification notification = new NotificationCompat.Builder(MainActivity.this, CHANNEL_ID)
.setContentTitle("New Messages")
.setContentText("You've received 3 new messages.")
.setSmallIcon(R.drawable.ic_notify_status)
.setNumber(messageCount)
.build();
notificationManager.notify(notificationID, notification);
//Now update the message count
messageCount++;
Notification notification = new NotificationCompat.Builder(MainActivity.this, CHANNEL_ID)
.setContentTitle("New Messages")
.setContentText("You've received 3 new messages.")
.setSmallIcon(R.drawable.ic_notify_status)
.setNumber(messageCount)
.build();
notificationManager.notify(notificationID, notification);