19

This may be off topic, but I couldn't found anything for it.

Is there any limit on the number of notifications android app can display? I am facing issue after 100 notifications. There is no documentation which states this clearly.

Note: This is not really a good idea to show 100 notifications but It is required for certain reasons.

Benjamin Loison
  • 3,782
  • 4
  • 16
  • 33
MohK
  • 1,873
  • 1
  • 18
  • 29
  • 3
    @SharpEdge I don't know about you, but I usually issue Notifications programmatically. – Mike M. Oct 27 '15 at 09:54
  • yes I thought of that , but for getting responces from developer community , I asked here. – MohK Oct 27 '15 at 09:55
  • @MikeM. "the number of notifications limit" the limit may be implemented by the vendor depending on their UI Look feel, since OP has said he hasn't found any documentation regarding it. And i know that notifications are issued programmatically, it has nothing to do with that though, – Sharp Edge Oct 27 '15 at 09:56
  • @SharpEdge I agree that you may be correct on that point, but this question is not wholly unrelated to programming. – Mike M. Oct 27 '15 at 09:57

5 Answers5

10

According to @Nirel's answer.

1) I tried to run the code in 3 different devices.

Surprisingly notifications beyond 50 are not showing in notification area.

It gives following error.

W/NotificationManager﹕ notify: id corrupted: sent 51, got back 0

The same error comes for subsequent calls.

I saw the source of NotificationManager, it gives this error if incoming and out id is not same. See below code.

https://github.com/android/platform_frameworks_base/blob/master/core/java/android/app/NotificationManager.java#L233

2) After I tried to notify on intervals of 100 milliseconds.

It also gives the same error. What I tried is removed 1 notification when code is executed.

Surprisingly, notification number 153 came in status bar.

So the conclusion is that, at most 50 notifications can be there. This may be default behaviour and may can change by manufacturer as said by @Sharp Edge.

Thnx.

Benjamin Loison
  • 3,782
  • 4
  • 16
  • 33
MohK
  • 1,873
  • 1
  • 18
  • 29
10

In API23

package com.android.server.notification; NotificationManagerService.java

static final int MAX_PACKAGE_NOTIFICATIONS = 50;

The limit for notifications and toasts is per app 50

defim
  • 456
  • 6
  • 9
8

this post has really helped me to do research on this topic. I have written an article on this like how can you modify your logic and keep posting notifications even if you have reached the maximum limit by compromising on the oldest notifications. https://medium.com/mindorks/the-notification-limit-per-app-in-android-94af69a6862c

Dheeraj Sree
  • 81
  • 1
  • 2
  • That's pretty interesting. Although it's not a good UX to show such amount of notifications, but better to have an idea regarding the concept. BTW, I liked your article regarding WorkManager. Happy sharing. :) – MohK Aug 16 '19 at 04:42
6

The notification limit dropped from 50 to 24 per app
in the Android 10 notification drawer.

Read more about it here.

Serge Stroobandt
  • 28,495
  • 9
  • 107
  • 102
3

run this:

// prepare intent which is triggered if the
// notification is selected

Intent intent = new Intent(this, NotificationReceiver.class);
// use System.currentTimeMillis() to have a unique ID for the pending intent
PendingIntent pIntent = PendingIntent.getActivity(this, (int) System.currentTimeMillis(), intent, 0);

// build notification
// the addAction re-use the same intent to keep the example short
Notification n  = new Notification.Builder(this)
        .setContentTitle("New mail from " + "test@gmail.com")
        .setContentText("Subject")
        .setSmallIcon(R.drawable.icon)
        .setContentIntent(pIntent);

NotificationManager notificationManager = 
  (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

for(int i = 0;i<1000;i++)
{
Log.d("Tag", "notification number" + i "just published")
    notificationManager.notify(i, n); 
}

when the application will crash you will see how much notification you have..

Nirel
  • 1,855
  • 1
  • 15
  • 26