Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android notification not showing more than 3 actions

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);
like image 535
aloj Avatar asked Mar 01 '17 14:03

aloj


People also ask

Is there a limit to notifications?

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.

Why are my notifications not showing up on Android?

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.

How do I change the notification limit on Android?

Limit notifications to certain apps Notification management is in Settings -> Sound & notification. In App notifications, you can access the settings for each app individually.


2 Answers

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

like image 64
Pavneet_Singh Avatar answered Nov 16 '22 04:11

Pavneet_Singh


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.

like image 36
zsmb13 Avatar answered Nov 16 '22 03:11

zsmb13