'Android 12 upgrade lost Mediastyle notification color

My samsung a52 recently upgraded from 11 to 12, and lost the notification colorisation ...

Here is the code :

   private void showPlayingNotification() {

    Context context = MyApplication.getInstance().getApplicationContext();

    Intent resumeIntent = new Intent(context, MainActivity.class);
    PendingIntent pendingResumeIntent = PendingIntent.getBroadcast(context, 12345, resumeIntent, PendingIntent.FLAG_UPDATE_CURRENT);

    Notification.Builder mBuilder = new Notification.Builder(context, NOTIFICATION_CHANNEL_ID);

    mBuilder.addAction(R.drawable.ic_back30, "rw30", MediaButtonReceiver.buildMediaButtonPendingIntent(this, PlaybackStateCompat.ACTION_REWIND))
            .addAction(R.drawable.ic_player_pause, "Pause", MediaButtonReceiver.buildMediaButtonPendingIntent(this, PlaybackStateCompat.ACTION_PLAY_PAUSE))
            .addAction(R.drawable.ic_forward30, "ff30", MediaButtonReceiver.buildMediaButtonPendingIntent(this, PlaybackStateCompat.ACTION_FAST_FORWARD))
            .addAction(android.R.drawable.ic_menu_close_clear_cancel, "Stop", MediaButtonReceiver.buildMediaButtonPendingIntent(this, PlaybackStateCompat.ACTION_STOP))

            .setStyle(new Notification.MediaStyle()
                    .setShowActionsInCompactView(0,1,2)
                    .setMediaSession((MediaSession.Token) mMediaSessionCompat.getSessionToken().getToken()))

            .setSmallIcon(R.drawable.ic_rss_icon)
            .setLargeIcon(mMediaSessionCompat.getController().getMetadata().getDescription().getIconBitmap())
            .setContentIntent(pendingResumeIntent)
            .setColorized(true);


    startForeground(12345, mBuilder.build());
}

Now even if I include '.setcolorized(true)' it results in a white background notification (instead of the colorized I had with android 11) ...

Any clue ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source