I have been having trouble with a icon showing with my notification. I have gone trough the material designs page for icons and Notification doc.
I used different scales, in BMP 256 color format: 360px, 144px, 48px, 24px 16px all continued showing a white block.
I changed format to PNG, used 144px (named "ic_notify_icon", used in code), still no luck.
//Global
private NotificationManager mNotifyManager ;
private Notification mNotify;
private void initialize() {
mNotifyManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification.Builder mNotificationBuilder = new Notification.Builder(this);
mNotificationBuilder.setSmallIcon(R.mipmap.ic_notify_icon);
mNotificationBuilder.setContentTitle("A Title here");
mNotificationBuilder.setContentText("Some content text here");
mNotify = mNotificationBuilder.build();
ShowNotify();
}
private void ShowNotify(){
//...some code here
mNotifyMan.notify(0, mNotify);
//...some code here
}
Any suggestions?
p.s. I had a look at this post, also same question but I do not find it helpful/useful, or I just do not understand the requirements...
I have found the solution!
I only found hints on what the requirements are for a Android Notification (SDK 22 / Version 5.1.1)but after searching for over 4 hours, finally a complete and working solution for this.
Here are the steps I followed and it seems to be inline with what is mentioned on various forums, questions/answers and doc, but no "steps/requirements" of what is needed:
Creating and preparing your image
click File > Save As or press 's'
You should have a Save Dialog
open (and a save options dialog, top right - if not, right at the bottom of the save dialog, select the Save options dialog
checkbox, and it should open)
My settings (which were given by default) are:
Check the following 2 boxes:
In Android Studio:
Right-Click Drawable folder > Add image asset
(any resource folder should do)
Notification Icon
from the top drop-down list (default is Launcher Icon
)
Image > Browse to image> click ok
You will notice your image is greyscale this is normal since the Lollipop SDK (API 21 - Ver 5.0.1)
only allows this type of color scheme, in searching I came across the materials design page which mentioned something in this line (Someone can extend on why this is)
Below, you will notice your notification icon in different 'dpi resolutions', adding a image normally will show a white block, but adding transparency solves this.
I believe one can use this from a 'colorful' perspective, in this case, IrfanView has a default background of black, this creating a "inverted" image in respect to this color (assuming in IrfanView, one leaves the "Use main windows color for transparency - checked" ) you can create different and interesting images.
I really hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With