As you already know that Android Oreo introduced the new design for media controls, rather than selecting a singular color for the notification based on the app's color, media playback notifications can instead draw colors out of the album artwork. Android then uses those colors to make a notification that blends the artwork into the notification while making the notification itself pop in your notification shade.
May I know how we can do this ?
To add an image in your notification, pass an instance of NotificationCompat. BigPictureStyle to setStyle() .
This is MediaStyle for Notification. You need to set MediaStyle and media session tokon and thats it. For example:
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID);
//building some actions...
builder.setSmallIcon(R.mipmap.ic_launcher)
.setStyle(new android.support.v4.media.app.NotificationCompat.MediaStyle()
.setShowActionsInCompactView(0, 1, 2)
.setShowCancelButton(true)
.setMediaSession(mediaSessionCompat.getSessionToken()))
.setCategory(NotificationCompat.CATEGORY_TRANSPORT)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setShowWhen(false)
.setContentTitle("Title Name")
.setContentText("Content text")
.setSmallIcon(R.drawable.pause)
.setWhen(0)
.setAutoCancel(true)
.setLargeIcon(icon);
You can find tutorial here: Tutorial
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With