androidandroid-notificationsandroid-notification-bar

How to remove "+999" from notification?


I am using below code to show inbox style notification in android app. In API 23 and below "+999" is showing bottom right side when I am expanding the notification,

But in API 24 and above "+999" text not visible.

Notification.Builder mBuilder = new Notification.Builder(this);
    mBuilder.setAutoCancel(true);
    mBuilder.setContentTitle("Notification");
    mBuilder.setLargeIcon(icon);
    mBuilder.setContentText(mainMessage);
    mBuilder.setGroupSummary(true);
    mBuilder.setGroup(GROUP_KEY_BUNDLED);

Notification.InboxStyle inboxStyle = new Notification.InboxStyle();
inboxStyle.setBigContentTitle("Notification:");
// add lines 
for (String message : mMessagesList) {
    inboxStyle.addLine(message);
}
mBuilder.setNumber(mMessagesList.size());

if(mMessagesList.size() > 7){
    inboxStyle.setSummaryText("+7 more Notification");
}

mBuilder.setStyle(inboxStyle); 

Screenshot(API level 23) enter image description here

Screenshot(API level 26) enter image description here

How to remove "+999" from notification ?


Solution

  • After testing your code i found the issue. The issue in your mMessagesList size. Api level 23 and below section the notification style different from API 26+. When you set mBuilder.setNumber(mMessagesList.size()) then the issue occurred.

    If the number size 1000 or upper then the number will show 999+.

    I think you are testing the notification with dummy message and the message list greater than or equal 1000.

    So for real situation you will get exact number. You can check API level for showing number or not.

    I think you got the idea.