Android: Media notification

813 views Asked by At

I am working on a music application, and I am showing the media details on notification with media action buttons, now when I run my app on android 12, I see everything working as intended, but on android 13, I cannot see the next and previous action buttons.

Where I am going wrong here? Below are the screenshots for easy reference.

enter image description here

enter image description here

Notification notification = new NotificationCompat.Builder(mContext, CHANNEL_ONE_ID)
                .setSmallIcon(R.mipmap.ic_music)
                .setContentTitle(title)
                .setContentText(description)
                .setContentIntent(actionOnClick)
                .setLargeIcon(bitmap)
                .setStyle(new androidx.media.app.NotificationCompat.MediaStyle()
                        .setShowActionsInCompactView(0, currSong.isCurrentPlaying() ? 1 : 3, 2)
                        .setMediaSession(mediaSession.getSessionToken()))
                .addAction(new NotificationCompat.Action(R.drawable.ic_music_previous,
                        "Previous",
                        MediaButtonReceiver.buildMediaButtonPendingIntent(mContext,
                                PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS)))
                .addAction(new NotificationCompat.Action(PlayerConstants.SONG_PAUSED ? R.drawable.ic_music_play : R.drawable.ic_music_pause,
                        PlayerConstants.SONG_PAUSED ? "Play" : "Pause",
                        MediaButtonReceiver.buildMediaButtonPendingIntent(mContext,
                                PlayerConstants.SONG_PAUSED ? PlaybackStateCompat.ACTION_PLAY : PlaybackStateCompat.ACTION_PAUSE)))
                .addAction(new NotificationCompat.Action(R.drawable.ic_music_next,
                        "Next",
                        MediaButtonReceiver.buildMediaButtonPendingIntent(mContext,
                                PlaybackStateCompat.ACTION_SKIP_TO_NEXT)))
                .setAutoCancel(false)
                .setPriority(NotificationCompat.PRIORITY_HIGH)
                .build();

        getNotificationManager().notify(1, notification);
0

There are 0 answers