u2gilles u2gilles - 1 month ago 7x
Android Question

Android MediaStyle NotificationCompat displays 3 actions maximum

I have 2 problems with my NotificationCompat.Builder set up as MediaStyle :

1) I set up 5 actions and only 3 are displayed in the expanded notification. (The first 3 displayed actions are working fine).

2) None action is displayed in the compact notification though I set up 1 action.

I'm testing on a Samsung S4 on Lollipop 5.1.1 (Cyanogen) and my app uses support library 23.2.1

Below is my NotificationCompat.Builder :

notificationBuilder = new NotificationCompat.Builder(act)
.setStyle(new MediaStyle()
.setShowActionsInCompactView(new int[]{1})


I have found the reason for this problem. I used the v4 appcompat support library instead of the v7

So replacing :

import android.support.v4.app.NotificationCompat;

by :

import android.support.v7.app.NotificationCompat;

fixed the problem.

This also was the reason of another of my issues with the media style notification.