Android notifications show no more than three actions

I want to display a notification with 5 actions, but it displays 3 of them. This is the code I use to display 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);
+4
source share
2 answers

you can only show max 3 actions as indicated in the Notification.Builder addAction (Notification.Action action)same

The notification in its expanded form can display up to 3 actions, starting from left to right in the order in which they were added.

Alternatively you create a custom one RemoteViewsand usesetCustomContentView

Link

Read custom notification layouts

Adding a button action to a custom notification

+5
source

Source: https://habr.com/ru/post/1671147/


All Articles