Why NotificationCompat MediaStyle notification is not showing all five buttons in expanded view in Android

105 views Asked by At

I am trying to show 5 actions in the expanded media notification in Android but no matter, both the collapsed and expanded notifications are only showing three actions (prev, play/pause, next). In extended view, I also want to show rewind and fast-forward. What am I missing? I tested on Samsung Galaxy 22 (Android 13) and Google Pixel 5a (Android 14).

    val skipToPreviousAction = NotificationCompat.Action(
        prevIcon,
        "Skip Backwards",
        MediaButtonReceiver.buildMediaButtonPendingIntent(context, component,
           PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS)
    )
    ...
    val builder = NotificationCompat.Builder(context, channelId)
        .setSmallIcon(R.drawable.app_logo_24)
        .setLargeIcon(largeBitmap)
        .setContentIntent(buildContentIntent())
        .setTicker(title)
        .setAutoCancel(false)
        .setLocalOnly(true)
        .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
        .setPriority(NotificationCompat.PRIORITY_MAX)
        .setCategory(NotificationCompat.CATEGORY_TRANSPORT)
        .addAction(skipToPreviousAction)
        .addAction(rewindAction)
        .addAction(if (isPlaying) pauseAction else playAction)
        .addAction(fastForwardAction)
        .addAction(skipToNextAction)
        .setOngoing(isPlaying)
        .setOnlyAlertOnce(true)
        .setStyle(androidx.media.app.NotificationCompat.MediaStyle()
            .setMediaSession(token)
            .setShowActionsInCompactView(0, 2, 4) 
            //.setShowActionsInCompactView(0, 1, 2, 3, 4) // tried just in case but no use 
            .setCancelButtonIntent(cancelButtonIntent)
            .setShowCancelButton(true))

Those three buttons are working but never show all five.

Update: Not seeing this issue in Android 9 Samsung S9 - so seems like OS/device specific.

0

There are 0 answers