8

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);
aloj
  • 3,194
  • 7
  • 27
  • 38

2 Answers2

10

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

Community
  • 1
  • 1
Pavneet_Singh
  • 36,884
  • 5
  • 53
  • 68
2

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.

zsmb13
  • 85,752
  • 11
  • 221
  • 226