I have this code:
Notification notif;
// Build notification
Notification.Builder notifBuilder = new Notification.Builder(context);
notifBuilder.setContentIn
As noted in Android 5.0 Behavior Changes of the Android Developers site under Notifications:
Notifications are drawn with dark text atop white (or very light) backgrounds to match the new material design widgets. Make sure that all your notifications look right with the new color scheme. If your notifications look wrong, fix them:
Use setColor() to set an accent color in a circle behind your icon image. Update or remove assets that involve color. The system ignores all non-alpha channels in action icons and in the main notification icon. You should assume that these icons will be alpha-only. The system draws notification icons in white and action icons in dark gray.
http://developer.android.com/about/versions/android-5.0-changes.html.
Add this in your manifest -
<meta-data android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_notification" />
In Android 5.0 the icon showed in the status bar is a white square because of 5.0 Lollipop "Notification icons must be entirely white".
You can easily find this types of icons on the Material icon. Visit: https://material.io/icons/
Google also suggests that we use a custom color that will be displayed behind the white notification icon using setColor()
method.
For more information visit: https://developer.android.com/about/versions/android-5.0-changes.html
Duplicate : Notification bar icon turns white in Android 5 Lollipop
In a Brief :
Android 5 update : https://developer.android.com/about/versions/android-5.0-changes.html Notifications -> Material design style
Update or remove assets that involve color. The system ignores all non-alpha channels in action icons and in the main notification icon. You should assume that these icons will be alpha-only. The system draws notification icons in white and action icons in dark gray.
It's possible to set the small icon background color using (default is gray) :
Notification.Builder#setColor(int)
Anyone still looking at this, the simplest way of getting your icon to display correctly is first rendering it with the Android Icon Studio here:
https://romannurik.github.io/AndroidAssetStudio/icons-notification.html
Unzip the files from the downloaded zip into your project /main folder, so they slot into the relevant drawable-xxxx folders.
Then, to change colour in the notification use something like this:
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_ID)
.setSmallIcon(R.drawable.ic_notification_appicon) // <-- Icon from Android Icon Studio
.setColor(context.getColor(R.color.holo_blue)) // <-- Set your preferred icon colour to appear in the notification dropdown list
.setContentTitle("Title")
.setContentText("Content")
.setAutoCancel(true)
.setCategory(NotificationCompat.CATEGORY_EVENT)
.setDefaults(Notification.DEFAULT_ALL)
.setPriority(NotificationCompat.PRIORITY_DEFAULT);
I have resolved changing the icon size to 16x16 px and using only white color