为什么我的通知图标在Oreo中无法正确显示? [英] Why is my notification icon not displayed properly in Oreo?
问题描述
很长一段时间以来,我们的应用程序中都有通知,这些通知都可以正常运行.我有一个供他们使用的彩色的小.png图标,过去效果很好.
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.
在奥利奥(Oreo)中,图标显示不正确,只是一个灰色方块.看着设备上的抽屉,看来系统,gmail等现在都是单色的.图标,所以我怀疑这与它有关.
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...
如何在Oreo中正常显示图标?我想念什么?
How can i make my icon display as normal in Oreo? What am i missing?
这是我创建图标的方式,根据我在文档中看到的内容,它应该可以工作,并且可以在Oreo之前运行:
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 https://developer.android.com/about/versions/android-5.0-changes.html after 5.0 it may change your icon due to this.
这篇关于为什么我的通知图标在Oreo中无法正确显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!