Notification icon on status bar is coming as white box - android

How do i customize the notification icon on the status bar in my phone running Android 5.0. It always comes as a white box(image attached).
The notification icon in the notification bar comes colorful as expected but the status bar icon comes as white square box.l

android 5.0 uses the icon that you give him and puts a color filter on it. If you want to see your icon, you must use an icon with transparency (png). I advice you to set another icon other than the icon of your application and remove the rectangle with rounded border.

There is some restrictions for notification icons. And also Lollipop doesn't show exactly what you set. It flatifies the notification icons and also suggest you to use flat style icons.

Related

What is this Android icon that looks like a gauge with a leaf?

Screenshot of the icon below, with a square drawn around it.
Note: This icon is not permanently displayed. The notification shade must be pulled down for the icon to appear in the notification bar.
The icon is showing the status of the Samsung "Performance Profile".

How can we use multi color icon in android notification icon

I have already tried with transparent background, it's working fine but I need more than 1 color in the notification small icon.
When I am trying to get results find whatever color we use that will change by icon color what we give in our code only transparent color is always transparent.
I have tried custom layout notifications but I got stuck with android 11 some devices work fine but some devices show a grey square icon.
I want a notification icon with multi-color in the status bar and when we expand notifications.
As of android V5.0.0 i.e target sdk version 21, android will always tint your notification icon on the status bar. On Scrolling down the notifications on your lock screen in the newer version you can show a custom icon that can be of any color but on the status bar you wont be able to show multi color icons.

How to support multiple colors (more than two color) for Android Notification icon?

I am working on Android app (API level >23). And I have to
support Notification.
And my notification icon is supported more than two colors.
If I use that icon then icon displays in grey in notification
pannel.
So I have created background transparent and completly white icon
and set color dynamically.
But I am able to set only one color (setColor()).
So my question is :-
How to support multiple colors (more than two color or color gradients) for Android Notification icon?
Note :- I have taken reference of Android Push Notifications: Icon not displaying in notification, white square shown instead
Thanks for support in advance.
If your app targets SDK 21+ the system will always tint your notification icon
white when it's displayed in a dark status bar
dark grey when it's displayed on a light status bar (API 23+)
dark grey when it's collapsed at the bottom of the notification shade
the color you set when it's part of a notification in the notification shade (API 24+, before that you'd have a white icon over a colored circle as the default large notification icon)
You have no control over the color other than what's described above.
But you can work with alpha channel. You can achieve different degrees of white/dark grey/color in your icon.
No, there's no other way. Pass this on to your designer and management.
Android 5.0 Behavior Changes
Notifications
Material design style
Update or remove assets that involve color. The system ignores all non-alpha channels in action icons and in the main notification icon. You should assume that these icons will be alpha-only. The system draws notification icons in white and action icons in dark gray.
Source: https://developer.android.com/about/versions/android-5.0-changes.html#NotificationsMaterialDesignStyle
Notifications
Make sure your notifications take these Android 5.0 changes into account. To learn more about designing your notifications for Android 5.0 and higher, see the notifications design guide.
Material design style
Notifications are drawn with dark text atop white (or very light) backgrounds to match the new material design widgets. Make sure that all your notifications look right with the new color scheme. If your notifications look wrong, fix them:
Use setColor() to set an accent color in a circle behind your icon image.
Update or remove assets that involve color. The system ignores all non-alpha channels in action icons and in the main notification icon. You should assume that these icons will be alpha-only. The system draws notification icons in white and action icons in dark gray.
from:
https://developer.android.com/about/versions/android-5.0-changes.html#NotificationsMaterialDesignStyle

Notification icon showing up in status bar but not in notification itself

As you can see, the mipmap icon is showing in the status bar but not in the notification itself. This is how I've set it:
Notification notification = new NotificationCompat.Builder(this).
setSmallIcon(R.mipmap.ic_launcher). // This is the small icon
// more code
build();
Current test device is using Android 7.1.1
Can anyone help or explain why this is happening, or give some advice on how to fix it? Thanks
This is because Android requires a white icon in the notification bar. So change it to a white icon.
https://developer.android.com/guide/topics/ui/notifiers/notifications.html
What Android basically does, is painting your wall grey. Actually your wall is showing, but with a grey overlay.
According to your question below, you can load your drawable and paint it to white like this:
yourWallIcon.setColorFilter(Color.WHITE)
Note that yourWallIcon must be a drawable.

Why do icons set with Notification.Builder.setSmallIcon in Android Lollipop show as a white square?

I have this code:
Notification notif;
// Build notification
Notification.Builder notifBuilder = new Notification.Builder(context);
notifBuilder.setContentIntent(pendingIntent);
notifBuilder.setContentTitle(title);
notifBuilder.setSmallIcon(icon_resId);
notifBuilder.setContentText(ne.getCaption());
notifBuilder.setDefaults(Notification.DEFAULT_ALL);
notifBuilder.setAutoCancel(autocancel);
notifBuilder.setWhen(System.currentTimeMillis());
notif = notifBuilder.build();
and works fine in Android 4.4.
However, in Android 5.0 the icon showed in status bar is a white square. The icon showed in the new "notification body", that appears when device is locked, is correct.
In http://developer.android.com/reference/android/app/Notification.Builder.html, I don't see anything new about notification icons in API Level 21
Look at the documentation:
http://developer.android.com/design/style/iconography.html
there are words: "Notification icons must be entirely white. Also, the system may scale down and/or darken the icons."
I have resolved changing the icon size to 16x16 px and using only white color
As noted in Android 5.0 Behavior Changes of the Android Developers site under Notifications:
Notifications are drawn with dark text atop white (or very light) backgrounds to match the new material design widgets. Make sure that all your notifications look right with the new color scheme. If your notifications look wrong, fix them:
Use setColor() to set an accent color in a circle behind your icon image.
Update or remove assets that involve color. The system ignores all non-alpha channels in action icons and in the main notification icon. You should assume that these icons will be alpha-only. The system draws notification icons in white and action icons in dark gray.
http://developer.android.com/about/versions/android-5.0-changes.html.
Duplicate : Notification bar icon turns white in Android 5 Lollipop
In a Brief :
Android 5 update :
https://developer.android.com/about/versions/android-5.0-changes.html
Notifications -> Material design style
Update or remove assets that involve color. The system ignores all
non-alpha channels in action icons and in the main notification icon.
You should assume that these icons will be alpha-only. The system
draws notification icons in white and action icons in dark gray.
It's possible to set the small icon background color using (default is gray) :
Notification.Builder#setColor(int)
Add this in your manifest -
<meta-data android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="#drawable/ic_notification" />
Anyone still looking at this, the simplest way of getting your icon to display correctly is first rendering it with the Android Icon Studio here:
https://romannurik.github.io/AndroidAssetStudio/icons-notification.html
Unzip the files from the downloaded zip into your project /main folder, so they slot into the relevant drawable-xxxx folders.
Then, to change colour in the notification use something like this:
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_ID)
.setSmallIcon(R.drawable.ic_notification_appicon) // <-- Icon from Android Icon Studio
.setColor(context.getColor(R.color.holo_blue)) // <-- Set your preferred icon colour to appear in the notification dropdown list
.setContentTitle("Title")
.setContentText("Content")
.setAutoCancel(true)
.setCategory(NotificationCompat.CATEGORY_EVENT)
.setDefaults(Notification.DEFAULT_ALL)
.setPriority(NotificationCompat.PRIORITY_DEFAULT);
In Android 5.0 the icon showed in the status bar is a white square because of 5.0 Lollipop "Notification icons must be entirely white".
You can easily find this types of icons on the Material icon.
Visit: https://material.io/icons/
Google also suggests that we use a custom color that will be displayed behind the white notification icon using setColor() method.
For more information visit: https://developer.android.com/about/versions/android-5.0-changes.html
Remove the android:targetSdkVersion="21" from manifest.xml.
it will work!

Categories

Resources