I want to display a notification with 5 actions, but it ony displays 3 of them. This is the code I'm using for displaying it
Notification notification =
new android.support.v7.app.NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("My notification")
.setContentText("Hello World!")
.addAction(new NotificationCompat.Action.Builder(R.drawable.action1, null, pendingIntent1).build())
.addAction(new NotificationCompat.Action.Builder(R.drawable.action2, null, pendingIntent2).build())
.addAction(new NotificationCompat.Action.Builder(R.drawable.action3, null, pendingIntent3).build())
.addAction(new NotificationCompat.Action.Builder(R.drawable.action4, null, pendingIntent4).build())
.addAction(new NotificationCompat.Action.Builder(R.drawable.action5, null, pendingIntent5).build())
.setAutoCancel(false)
.build();
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(MEETING_NOTIFICATION_ID, notification);
Have you ever wondered if there is any notification limit per application in Android. I never thought there was one until I actually tried it out. Yes, there is a limit of notifications that can be posted per app. The interesting thing was the number is not fixed and can be controlled by the device Manufacturer.
Cause of Notifications Not Showing up on Android Do Not Disturb or Airplane Mode is on. Either system or app notifications are disabled. Power or data settings are preventing apps from retrieving notification alerts. Outdated apps or OS software can cause apps to freeze or crash and not deliver notifications.
Limit notifications to certain apps Notification management is in Settings -> Sound & notification. In App notifications, you can access the settings for each app individually.
you can only show max 3 actions as mentioned in the Notification.Builder addAction (Notification.Action action)
too
A notification in its expanded form can display up to 3 actions, from left to right in the order they were added.
Alternatively you create custom RemoteViews
and use setCustomContentView
Reference
Read Custom Notification Layouts
Adding button action in custom notification
Notifications can only display 3 actions.
A notification in its expanded form can display up to 3 actions, from left to right in the order they were added.
Source, the offical Notification.Builder documentation: https://developer.android.com/reference/android/app/Notification.Builder.html#addAction(android.app.Notification.Action)
If you absolutely need more than 3 actions, you'll have to opt for a solution using a custom view to display in the notification.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With