We have notifications in our app since a long time, which work fine. I have a small, multicoloured .png-icon we use for them, that have worked fine in the past.
In Oreo, the icon is not displayed properly, it is just a grey square. Looking at the drawer on the device, it seems that the system, gmail etc. all now have single-colour icons, so i suspect that it has something to do with that.
However, i can't find any documentation, design guidelines or anything that confirm this, so i am surrendering to a question here...
How can i make my icon display as normal in Oreo? What am i missing?
This is how i create the icon, from what i can see in documentation it should work, and it works pre-Oreo:
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
builder.setAutoCancel(true).setContentTitle("Title").setWhen(when)
.setContentText(message).setDefaults(Notification.DEFAULT_ALL)
.setSmallIcon("icon.png").setContentIntent(contentIntent);
getNotificationManager(context).notify(NOTIFICATION_ID, builder.build());
refer this site
In this site you may see this
You can see that I have set different small icons. Small icon need to
be vector icon on Lollipop and upper Android versions. Otherwise it
will show colored dot only as small icon.
If you have png,jpeg,jpg image file then convert it to svg and import this svg file into android studio using "Vector Asset" option and you are ready to go!!
Related
I have an app on android that create home shortcut icon.
The image of the icon is image that i set programmatically from the drawable
Now the problem is, when the shortcut was created on the home screen it's created with white background.
How do i remove that white backgroubd and set image to full size of icon?
Thank you all..
EDIT: the app i was talking about is app that i developed using android studio and just want to set full size of image when i create home shortcut
This is highly dependent on the launcher you use. The image looks like the standard google android 8+ (?) icon shape.
I theory it could be part of the icon you created but since you are asking this I doubt it.
In older versions of android the outer shape of the icons were individual, while rather cool and the outline correctly shown while dragging them etc many complained about the lack of a uniform look of all the icons in the app drawer etc.
It was introduced to make all icons seem more uniform.
Long pressing an empty space in the Google Pixel launcher for example shows a choice to go into the settings for the launcher and there you can change the shape all icons should have:
In addition to this, apps can take advantage of the various shapes and adapt to them and fill them out so to speak. See for example the Chrome icon while changing the icon shapes in the launcher settings.
Introduced in android 8: The feature is called adaptive icons.
See the docs about adaptive icons here:
https://developer.android.com/guide/practices/ui_guidelines/icon_design_adaptive
That is because of adaptive icons - a feature of Android 8 and can't or shouldn't be changed. You can at best change the colour of the background.
i removed the white background from the launcher icon by following these guidelines https://developer.android.com/studio/write/image-asset-studio
a few more points
in the background layer, move the slider to resize the icon until you see no what would have been the white background.
in the manifest file, change the icons to reference the mipmap folder;
android:icon="#mipmap/yourlogo"
android:roundIcon="#mipmap/yourlogo"
In Redmi Note 5 Pro, I am using remoteviews for custom notifications. While doing this, the resource which i am passing using setsmallicon() is not being taken and plain solid square is being displayed. The resource is being used if it is not a custom notification.
Can someone help me solve this issue.
From android version lollpop onwards, they have made the changes for the notifications. When you are specifing the small icon, it should be of specific size as mentioned in this link.
The important thing is the image should be transparent and contains only white color.
Try using single color white with transparent background png file and add your icon in mipmap folder and your problem solved.
I wanted to ask how to change the app icon of my app on a Galaxy S7 running on Android Nougat (see attached screenshot) to fill the whole icon space.
Is there a way to do this?
EDIT: I think it's because these apps have square icons and mine is circular. Is there a way to make it square for Galaxy S7 Nougat devices and for all others round?
You can disable this by adding a meta-data element to your manifest:
<application>
<meta-data android:name="com.samsung.android.icon_container.has_icon_container" android:value="true"/>
</application>
This solution is only for user's end:
Go to settings -> display -> icon frames -> icon only.
This should change the icons into full size icons.
From https://developer.android.com/about/versions/nougat/android-7.1.html
Apps can now define circular launcher icons, which are used on devices that support them. When a launcher requests an app icon, the framework returns either android:icon or android:roundIcon, depending on the device build configuration. Because of this, apps should make sure to define both android:icon and android:roundIcon resources when responding to launcher intents. You can use Image Asset Studio to design round icons.
While that may not be sufficient to deal with Samsung's "special" white frame for icons, this gif shows a few ideas for creating icons that look good whether they are the normal size or framed "Squircle" style.
https://www.androidcentral.com/sites/androidcentral.com/files/article_images/2016/12/squircles.gif
In any event this means you now have to worry about a normal icon, a round icon and a Samsung-ized icon and there is no way to provide an icon for the Samsung-specific launcher design.
I met the same problem and tried various things. Now I found one interesting thing.
If you make an icon without any transparency, the icon will be the full size on the Nougat android phone. When I made an icon in the paint.exe and saved it as .png, there was no problem.
I think this will help you.
EDIT : below is what I met, explained in my comment
EDIT2 : the sizes and shapes of two icons (with and without transparency) are identical. the only difference is one has transparency and the other has white background. Definitely I don't mean that I deleted transparency and enlarged the image.
EDIT3 : more explanation about my icons #Hadas
I have tried built in tools in android studio using res -> new -> Image Asset and then selecting notification icon.But after selecting the images it shows some grey and black boxes and not image icon and doesn't show in notifications as well.
I have researched and found that image background should be transparent for it to work but that didn't work also. Also i have tried images of 24x24 size as recommended but couldn't get the icon working in my android app.
Thanks in advance for any useful suggestions.
For v21 and above--> In notification icon, only white and transparent colors are allowed. Use white color what u want to show, rest part make it transparent.
For v20 and below --> You can use any image with proper dimensions.
Refer here for details.
I'm trying to add an icon as indicated by number 5 in the image above. I'm using the InboxStyle class and the NotificationCompat.Builder to build it. I've already called setSmallIcon without luck. Any ideas?
Thanks!
As it turns out, this is simply a design change in the new version of Android.
Prior to Android 5.0 Lollipop, setLargeIcon sets the large icon on the left and setSmallIcon sets the small icon on the far right side, as you'd expect.
Starting in Android 5.0, setSmallIcon overlays a small icon on the bottom right corner of the large icon. As far as I can tell, there is no way to make the small icon appear on the far right in Lollipop. Please correct me if I'm wrong.