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
Checking If an Android Application Is Running in the Background
How to Change the Status Bar Color in Android
How to Show Current Location on a Google Map on Android Marshmallow
How to Format Date and Time in Android
How to Have Android Service Communicate With Activity
What's the Difference Between the Various Methods to Get an Android Context
Post Multipart Request With Android Sdk
Custom Listview Adapter With Filter Android
Sharedpreferences.Onsharedpreferencechangelistener Not Being Called Consistently
Retrieve a Fragment from a Viewpager
How to Connect to My Http://Localhost Web Server from Android Emulator
How to Handle Button Clicks Using the Xml Onclick Within Fragments
Android Gallery on Android 4.4 (Kitkat) Returns Different Uri For Intent.Action_Get_Content