0

How to visible notification icon without reduce target sdk version to 20 from >20. my Notification Icon is colour icon,not Transparent. I used below Code but its not working In case of Lollipop.It showing only White background.

NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    builder.setSmallIcon(R.drawable.icon_colour);
} else { 
    builder.setSmallIcon(R.drawable.icon_colour);
}

1 Answers1

0

Android Lollipop notification icons are meant to be displayed in white style.

There is a documentation for "Android 5.0 behavior changes"

Notifications are drawn in dark text on white backgrounds (or very light) to match the new widgets of the design material.

This documentation also suggests that you use a color that will be displayed behind the (white) notification icon, where it says:

Use setColor () to set a highlight color in a circle behind the icon image.

Your solution should be used different rules for each Android version, which you are already using with android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP

Try updating your answer with that:

if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    builder.setSmallIcon(R.drawable.icon_no_colour);
    build.setColor(R.color.icon_background_color);
} else { 
    builder.setSmallIcon(R.drawable.icon_colour);
}

setColor() documentantion

Naveen Tamrakar
  • 3,349
  • 1
  • 19
  • 28
GuilhermeFGL
  • 2,891
  • 3
  • 15
  • 33