Notification icon is grey in color in android 8.0. I want to display the app icon. I have tried the following code:
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_launcher_round" />
But it is not working. Please help!
The code should be like that:
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/statusbar_notification" />
More Information in the link here: Oreo (8.0) status bar notification icon all white
I hope to help you.
Try this snippet - Hope it'll solve your problem.
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID);
//building some actions...
builder.setSmallIcon(R.mipmap.ic_launcher_round)
.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);
For further details please take a look at official document - Notification Overview
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.