0

I'm doing push notifications for Android using Firebase Cloud Messaging, and everything is going well, but I'm wondering what's going on with the icon color in the system tray. It is being turned into a greyscale image instead of keeping its original color. I am able to colorize it with the setColor method, but I'd like the icon to not lose its color at all, is this possible? I have tried using a variety of different images with their own sizes, transparent/non-transparent, white background etc., based on some posts I could find. I could not seem to locate an answer on what is actually happening here. My compile/target sdk is 26 at the moment. I'm using Android 8.0 and 9.0 on emulators (Nexus 6), and 8.1 on a physical device.

.setSmallIcon(R.drawable.app_logo)
.setColor(Color.GREEN)

Notification tray icon color is grey

Alex
  • 3,861
  • 5
  • 28
  • 44
  • It's possible the color is only for the large icon, and that the small icon must remain uncolored. What happens if you change your code to use `.setLargeIcon()`? – prfarlow Jul 26 '19 at 16:41
  • That's the one on the righthand side isn't it? I tried anyways and got: `Invalid notification (no valid small icon)`. I tried setting both and the small icon is still grey, but the large icon shows up normally with color. – Alex Jul 26 '19 at 16:53
  • Take a look at this [SO answer](https://stackoverflow.com/a/45883564/11016588). – Chrisvin Jem Jul 26 '19 at 16:55
  • @ChrisvinJem Every answer in that post (unless I missed one?) concerns using `setColor` - which I'm trying to avoid. – Alex Jul 26 '19 at 17:18
  • Can I know in which device are you checking?? Android version and device company? – Naitik Soni Jul 30 '19 at 06:29

1 Answers1

0

It is a bit misleading in case of notification's small icon. If you'll use colored drawable - it will appear tinted in a color, that Android OS choses to use. That is the way it is. If you'll provide .setColor() attribute - it will use that as a tint. It's because small icon is for notification tray (and can be either white or black) and will be used also with app name in notification when you'll pull notification tray downwards. Sometimes it will be not tinted in notification tray on some devices made of chineezium (as my Xioami device does). Just give it to Google and commit to rules that Google made us to follow

Roman T.
  • 333
  • 3
  • 10