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

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.

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 to set different icons for app and for its notifications?

I'm using a picture with black background and white sign as an icon for my app. The problem is when I'm getting a notification a icon at the top of the display is completely white (I don't know why to be honest, when screen is locked it looks as originally).
I want to solve this problem by setting different icon for notifications, I can use this site, when I'm using a text icon generated by this site it works just fine.
I'm wondering how to set different icons for my app and its notifications, I know it's possible, but I only have folders that are used for both app and notification icon (drawable-[hdpi/mdpi/xhdpi/xxhdpi/xxxhdpi]).
The problem is when I'm getting a notification a icon at the top of the display is completely white (I don't know why to be honest, when screen is locked it looks as originally).
You set the SetSmallIcon() in the Notification.Builder.
To understand the Android documentation which is as follows – “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.”
you can convert your notification icon to an Android friendly one with a few clicks.
In Notification icon generator, open up your icon file. Convert all parts of the image that you don’t want to show to transparent pixels. All colors and non transparent pixels are displayed in white.
Problem solved, I added below to AndroidManifest.xml (application section)
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="#drawable/new_notification_icon" />

Why is my smallIcon for Notifications always greyed out?

I tried making the small icon exactly 16x16, gray-scaled, nothing but gray and white (the gray color being hex value 616161), to create a silhouette of my application icon.
Yet no matter what it just shows up as a white/gray square in the notifications. What am I doing wrong?
(My min api is 21, assuming it is relevant)
Follow this link
First let’s understand the Android documentation which is as follows
“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.”
Now this is easy to miss and I have seen many apps that are live in the app store with thousands of users who haven’t followed the mentioned guidelines.
So let me explain in detail how you can convert your notification icon to an Android friendly one with a few clicks.
In your favourite image editor open up your icon file. Convert all parts of the image that you don’t want to show to transparent pixels. All colors and non transparent pixels are displayed in white. Let us go through an example.
EDITED: Thanks #Andrey Patseiko for the tool
For notification you have to use different icons for different versions of android:
Notification notification = new Notification.Builder(context)
.setAutoCancel(true)
.setContentTitle("My notification")
.setContentText("Look, white in Lollipop, else color!")
.setSmallIcon(getNotificationIcon())
.build();
return notification;
Get notification icon on the basis of version
private int getNotificationIcon() {
boolean useWhiteIcon = (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP);
return useWhiteIcon ? R.drawable.icon_silhouette : R.drawable.ic_launcher;
}
Along with new features and capabilities, Android 5.0 includes a variety of system changes and API behavior changes. See the notification behavior changes.
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.
So, basically you have to use silhouette icons as notification icon for API Level 21+

Android 5.0 Notification

Every time I run my application, the notification symbol in the notification bar is just a white square. My notification worked fine on all other android versions except for lollipop. I have looked at other threads and they don't seem to work. Anyone have any suggestions?
I have attached a picture of the notification icon I want to use:
http://i.stack.imgur.com/XhJcA.gif
It is a 48x48 gif. file with a transparent background. I have also tried a 16x16 gif file and I still had no luck.
Lollipop changes the notification styling according to this Behavior Changes. It changes the background of the notification circle to be white so white on white will not work, but you can change that to any color you want by
int color = getResources().getColor(R.color.my_notif_color);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setColor(color);
....
As hegazy has explained the new notification styling causes that.
Notice that if you are not using any new functionality, as a workaround you can stay with previous styling by setting the target SDK to 20 max: android:targetSdkVersion="20"

Notification icon on status bar is coming as white box

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.

Categories

Resources