Reputation: 7383
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)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setCategory(NotificationCompat.CATEGORY_TRANSPORT)
.setContentTitle(podcastName)
.setContentText(episodeName)
.setOngoing(true)
.setShowWhen(true)
.setContentIntent(activityMainPI)
.setSmallIcon(smallIcon)
.setLargeIcon(largeIcon)
.setAutoCancel(false)
.addAction(previousAction)
.addAction(playAction)
.addAction(nextAction)
.addAction(rewindAction)
.addAction(forwardAction)
.setStyle(new MediaStyle()
.setShowActionsInCompactView(new int[]{1})
);
Upvotes: 0
Views: 1384
Reputation: 7383
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.
Upvotes: 2
Reputation: 7383
Eugen, please find the first action (the others are similar) :
previousPI = PendingIntent.getBroadcast(context, 100, new Intent(TOOLS_CONST.ACTION_PREVIOUS), 0);
previousAction = new NotificationCompat.Action.Builder(R.drawable.ic_action_previous_light, null, previousPI).build();
Upvotes: 0