Why do icons set with Notification.Builder.setSmallIcon in Android Lollipop show as a white square?

Borja picture Borja · Nov 28, 2014 · Viewed 66.4k times · Source

I have this code:

Notification notif;

// Build notification
Notification.Builder notifBuilder = new Notification.Builder(context);
notifBuilder.setContentIntent(pendingIntent);
notifBuilder.setContentTitle(title);
notifBuilder.setSmallIcon(icon_resId);
notifBuilder.setContentText(ne.getCaption());
notifBuilder.setDefaults(Notification.DEFAULT_ALL);
notifBuilder.setAutoCancel(autocancel);
notifBuilder.setWhen(System.currentTimeMillis());
notif = notifBuilder.build();

and works fine in Android 4.4.

However, in Android 5.0 the icon showed in status bar is a white square. The icon showed in the new "notification body", that appears when device is locked, is correct.

In http://developer.android.com/reference/android/app/Notification.Builder.html, I don't see anything new about notification icons in API Level 21

Answer

porlicus picture porlicus · Dec 4, 2014

Look at the documentation: http://developer.android.com/design/style/iconography.html

there are words: "Notification icons must be entirely white. Also, the system may scale down and/or darken the icons."