Notification Bar Icon Turns White in Android 5 Lollipop

Notification bar icon turns white in Android 5 Lollipop

The accepted answer is not (entirely) correct. Sure, it makes notification icons show in color, but does so with a BIG drawback - by setting the target SDK to lower than Android Lollipop!

If you solve your white icon problem by setting your target SDK to 20, as suggested, your app will not target Android Lollipop, which means that you cannot use Lollipop-specific features.

Have a look at http://developer.android.com/design/style/iconography.html, and you'll see that the white style is how notifications are meant to be displayed in Android Lollipop.

In Lollipop, Google also suggest that you use a color that will be displayed behind the (white) notification icon - https://developer.android.com/about/versions/android-5.0-changes.html

So, I think that a better solution is to add a silhouette icon to the app and use it if the device is running Android Lollipop.

For instance:

Notification notification = new Notification.Builder(context)
.setAutoCancel(true)
.setContentTitle("My notification")
.setContentText("Look, white in Lollipop, else color!")
.setSmallIcon(getNotificationIcon())
.build();

return notification;

And, in the getNotificationIcon method:

private int getNotificationIcon() {
boolean useWhiteIcon = (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP);
return useWhiteIcon ? R.drawable.icon_silhouette : R.drawable.ic_launcher;
}

Push notification icon is white above Lollipop

you can set white icon above lolipop using this method.

  if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) 
{
Bitmap icon = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher);
mBuliderREC.setLargeIcon(icon);
mBuliderREC.setSmallIcon(R.drawable.notification_icon);
} else {
mBuliderREC.setSmallIcon(R.drawable.ic_launcher);
}

Notification bar icon turns white in Android L

I have encountered this issue too, as you mention, if your ANDROID_BUILD_TARGET_SDK_VERSION = 21, it will change this notification into white.

The notification icon design guideline as this link.
http://developer.android.com/design/style/iconography.html



Related Topics



Leave a reply



Submit