通知中不显示按钮

Buttons are not displayed in notification

我正在服务 (MusicService) 中创建自定义通知并添加如下按钮。

//Notification
    Intent notIntent = new Intent(this, MainActivity.class);
    notIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
    PendingIntent pendInt = PendingIntent.getActivity(this, 0,
            notIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    //Play
    Intent playIntent = new Intent(this, MusicService.class);
    playIntent.setAction(ACTION_PLAY);
    PendingIntent pPlayIntent = PendingIntent.getService(this, 1,
            playIntent, 0);

    //Pause
    Intent pauseIntent = new Intent(this, MusicService.class);
    pauseIntent.setAction(ACTION_PAUSE);
    PendingIntent pPauseIntent = PendingIntent.getService(this, 1,
            playIntent, 0);

    //Previous
    Intent previousSongIntent = new Intent(this, MusicService.class);
    previousSongIntent.setAction(ACTION_PREVIOUS);
    PendingIntent pPreviousSongIntent = PendingIntent.getService(this, 1,
            previousSongIntent, 0);

    //Next
    Intent nextSongIntent = new Intent(this, MusicService.class);
    nextSongIntent.setAction(ACTION_NEXT);
    PendingIntent pNextSongIntent = PendingIntent.getService(this, 1,
            nextSongIntent,0);

    Notification.Builder builder = new Notification.Builder(this);
    builder.setSmallIcon(R.mipmap.ic_launcher)
            .setOngoing(true)
            .setContentText(songTitle)
            .setContentIntent(pendInt)
            .setPriority(Notification.PRIORITY_MAX)
            .setWhen(0)
            .addAction(R.drawable.ic_play_button, "PLAY", pPlayIntent)
            .addAction(R.drawable.ic_pause_button, "PAUSE", pPauseIntent)
            .addAction(R.drawable.ic_next_button, "NEXT", pNextSongIntent)
            .addAction(R.drawable.ic_previous_button, "PREV", pPreviousSongIntent);
      Notification notification = builder.build();
      startForeground(NOTIFY_ID, notification);

通知中不显示按钮图标。 用两根手指向下滑动通知显示文本(下一个播放暂停)。 我错过了什么吗?

使用 MediaStylesetShowActionsInCompactView

builder.setStyle(androidx.media.app.NotificationCompat.MediaStyle()
                    .setShowActionsInCompactView(0, 1, 2))

这里有完整的例子https://code.videolan.org/videolan/vlc-android/-/blob/master/application/vlc-android/src/org/videolan/vlc/gui/helpers/NotificationHelper.kt#L99