3

I'm presenting different notifications in different scenarios in my application. Those notifications are created using the following code:

    protected void updateNotificationProgress() {
    notification.setContentTitle(notificationConfig.getTitle())
            .setContentText(String.format(getString(R.string.in_progress_formatted_string), (Utils.getUploadedFilesCount(this) + 1), Utils.getTotalUploadCount(this)))
            .setContentIntent(notificationConfig.getPendingIntent(this))
            .setSmallIcon(notificationConfig.getIconResourceID())
            .setProgress(Utils.getTotalUploadCount(this), Utils.getUploadedFilesCount(this), false)
            .setOngoing(true);

    startForeground(UPLOAD_NOTIFICATION_ID, notification.build());
}

While on most devices (LG G3, Samsung Galaxy devices) this notification looks as follows:

enter image description here

enter image description here

On Nexus devices this icon looks like this:

enter image description here

enter image description here

Why does this happen, and what is the proper way to fix this?

halfer
  • 19,824
  • 17
  • 99
  • 186
Emil Adz
  • 40,709
  • 36
  • 140
  • 187

2 Answers2

2

Starting in I believe Lollipop the OS changes your icon to white scale automatically to keep notification icons consistent.

So basically what I am saying is if both devices are on lollipop your LG device is not following the rules google set with the notifications and changed them to not do that.

Edit

The reason you see that one app's notification icon in color is because their target SDK (17) is still below lollipop (21) so the rules do not apply to those notification icons

tyczj
  • 71,600
  • 54
  • 194
  • 296
  • while your answer is correct based on notification guidelines: http://developer.android.com/design/patterns/notifications.html, it does not answer my question. There is an example for an icon that looks right on all devices (including Nexus ones) and has color in it. you can see the suitcase icon in the last image. So there is a way to do this. my question is how? – Emil Adz Mar 21 '16 at 16:21
  • what app is that (one with the colored icon) if I may ask – tyczj Mar 21 '16 at 16:29
  • This application is called Hulyo: https://play.google.com/store/apps/details?id=com.devsense.hulyo – Emil Adz Mar 21 '16 at 16:30
  • as I suspected, that app's target sdk is 17 so the lollipop rules do not effect the icon. I just made a test example to verify and when I have my `targetSdkVersion` at 17 I get the color icon – tyczj Mar 21 '16 at 16:46
  • So you think once they update their targetSdkVersion their are going to have the same problem as I do? – Emil Adz Mar 21 '16 at 16:48
  • So, I can tell my bosses that their is no way to achieve their desired effect and I have to use white/transparent icon, or there might still be a way to achieve this? – Emil Adz Mar 21 '16 at 16:50
  • that would be correct, there is no way to do this anymore as the OS forcefully changes it for you. As a suggection what is wrong with making the text transparent (infi) in it? The icon is so small you will hardly tell the difference – tyczj Mar 21 '16 at 16:52
  • you can get a little more information from here if you need http://stackoverflow.com/questions/28387602/notification-bar-icon-turns-white-in-android-5-lollipop – tyczj Mar 21 '16 at 16:55
  • Ok, thank you very much for you help, Soon I will accept your answer. – Emil Adz Mar 21 '16 at 17:05
0

To avoid this kind of problem I check how my notification icon will looks like in Lollilop devices, using AndroidAssetStudio

I test your icon and definitely is just a white square.

Hope this helps to solve your issue!!

Gueorgui Obregon
  • 5,077
  • 3
  • 33
  • 57