Issue
Sometime back when I upgraded to lolipop on my Moto E the small notification icon turned black and white(I read that its the new google guidline). SO Ok I can live with it. Now I have noticed that the icon has turned color again, and I havent changed my code and have been using the same drawable. It sure was showing black and white and now its colored. My device is on Android 5.0.2 Also:
compileSdkVersion 22
buildToolsVersion "22.0.1"
targetSdkVersion 22
Here is my code:
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
this)
.setVibrate(new long[] { 10, 10, 10, 10, 10 })
.setSound(alarmSound)
.setSmallIcon(R.drawable.logo)
.setContentTitle(title)
.setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
.setContentText(msg);
Can anybody tell me how this happened?
Solution
It seems that ever since the android upgraded to lolipop the small icon on the notification comes in black and white only...
but it can be changed with the .setColor()
method as shown in the code below.
Here's the code to set the color of the notification icon:-
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
notificationBuilder.setSmallIcon(R.drawable.appypie_small);
notificationBuilder.setColor(getResources().getColor(R.color.notification_color));
}
else {
notificationBuilder.setSmallIcon(R.drawable.appypie_small);
}
Answered By - Gáüřãv Jõşhï
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.