I am using Notification.Builder to create a notification. For this notification I am using a level-list as the small Icon
mNotificationBuilder.setSmallIcon(R.drawable.icon_levellist, levelInt);
This sets the icon to the correct level in the status bar, however when pulling down the notification the icon is set to the default level.
I have tried using a custom layout in order to display this and it works, however I would like to be able to use the default layout that comes with Notification.Builder.
Is this a bug?
I think it is a bug as I am experiencing the same thing
You can star this issue:
http://code.google.com/p/android/issues/detail?id=43179&q=setSmallIcon&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars
Related
I am implementing custom push notifications. I have a custom layout, modified using RemoteViews. I have set color using
contentView.setInt(R.id.parentLayout, "setBackgroundColor", Color.parseColor("#4979C5"))
notifBuilder.setColor(Color.parseColor("#4979C5"))
.setColorized(true)
But it doesn't set color completely on background. I want it to have like this Android system notification
but I am getting this
Here is the styling that I have used:
notifBuilder.setColorized(true)
.setColor(Color.parseColor("#4979C5"))
.setStyle(NotificationCompat.DecoratedCustomViewStyle())
.setContent(closedView)
.setCustomBigContentView(contentView)
.setSmallIcon(R.drawable.icon_tick)
I have tried using other styles and also removed the style but I get this result
Which seems to be fine as it does have background color set on complete notification area but now there is no details like app name, notification time, app icon and expand icon. Even action buttons are gone.
I set up a ongoing notification with a foreground service. Here is the code.
NotificationCompat.Builder notificationBuilder= new NotificationCompat.Builder(this,"unique")
.setSmallIcon(R.drawable.ic_mms_black_24dp)
.setContentTitle("My notification")
.setContentText("Hello World!")
.setPriority(NotificationCompat.PRIORITY_DEFAULT);
Notification notification= notificationBuilder.build();
startForeground(MY_ID,notification);
But the icon that I have set at setSmallIcon() have no effect, instead it shows default app icon on status bar and notification panel which run on the Android 6. However After that I ran the above code on Android 5.1.1 (API LEVEL 22) and it shows the correct icon. I tried different types of icon (png,xml) and all worked well. But on my Marshmallow one It just shows the default app icon.
How do I figure out the reason?
From Android 6(Icon is at the left most corner):
From Android 5(Icon is at the left most corner):
EDIT: I tried a white icon too. But still notification shows the default app icon. Is there any size constraints of the icon? But xml icons are scalable right.
It seems like issue is from manufacture of the OS. There is a issue in EMUI 4.0+ that doesn't show custom notification icons. It only shows the application default icon in the status bar. If your model has EMUI It is the issue. This guide might help to fix the issue - How to enable ui tuner EMUI 4 .
It is most likely because your icon is black in color.
For latest Android versions, you need the notification icon to be white in color.
Status bar icons are composed simply of white pixels on a transparent
backdrop
You could checkout the guidelines here -
https://developer.android.com/guide/practices/ui_guidelines/icon_design_status_bar
Also make sure that you have all the correct sizes required by different screen densities as well.
Android Oreo has option to show notification dot for any new push notification. However, it is not documented anywhere whether it is possible to change the color of Notification dot programatically.
Any suggestions?
It seems that this color is taken based on app colors icon - probabbly most frequently used color.
My notification is currently a totally custom layout, as Spotify's used to be:
But I would like to show the app icon, name, and expand/collapse arrow as native Android 7 notifications now do. How do you get it to show the title and expand/collapse arrow, as Spotify now does?
I'm assuming it's still a custom layout. If not, how do you make custom buttons on a native layout? I know how to use the quick reply bar or inboxStyle, but those don't allow icons.
Thanks
That's not a custom notification - it is a standard MediaStyle notification as explained in the Using MediaStyle notifications guide.
If you find you do need a custom notification, you can also use the DecoratedMediaCustomViewStyle if you want to maintain the artwork style and automatic resizing used in MediaStyle 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"