HUSNAIN SARWAR HUSNAIN SARWAR - 4 months ago 37
Android Question

SmallIcon Color Turn To White Automatically Why In Notification Android?


import android.support.v4.app.NotificationCompat; public void
animatedNotification(){

NotificationCompat.Builder mBuilder =
new android.support.v4.app.NotificationCompat.Builder(context)
.setSmallIcon(ic).setLights(Color.GREEN, 10000, 10000)
.setWhen(when).setPriority(Notification.PRIORITY_HIGH)
.setContentTitle(title)

.setContentText("Plants Need Watering Some of Your work is pending");


NotificationManager mNotificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); // mId
allows you to update the notification later on.
mNotificationManager.notify(0, mBuilder.build());

}

Answer
.setSmallIcon(android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP ? R.mipmap.ic_launcher : R.drawable.notification_icon_bw_xhdpi)
.setColor(ResourcesCompat.getColor(getResources(), R.color.primary, getTheme()))

Use color to distinguish your app from others. Notification icons should only be a white-on-transparent background image. (https://developer.android.com/design/patterns/notifications.html)

Before lollypop you can use same mipmap icon for all notification icon. But from lollypop onwards you need to create new notification icon (Silhoette kind of icon).