android - 为什么我的通知图标在 Oreo 中显示不正确?

标签 android notifications android-8.0-oreo

很长一段时间以来,我们的应用程序中都有通知,效果很好。我有一个我们为他们使用的小型彩色 .png 图标,它在过去运行良好。

在Oreo中,图标显示不正确,只是一个灰色的方 block 。看设备上的抽屉,系统,gmail等现在似乎都是单色的图标,所以我怀疑它与此有关。

但是,我找不到任何文档、设计指南或任何证实这一点的东西,所以我在这里投降了一个问题......

如何让我的图标在 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 在这个网站上你可能会看到这个

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.

如果您有 png、jpeg、jpg 图像文件,然后将其转换为 svg 并使用“Vector Asset”选项将此 svg 文件导入到 android studio 中,您就可以开始了!

关于android - 为什么我的通知图标在 Oreo 中显示不正确?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46557873/

相关文章:

Android识别android通知栏上部的内容

android - Android中的菜单,应用程序无法启动

Android 构建 : No rule to make target `frameworks/base/preloaded-classes

swift - 在 Swift 2.1 中通过 NSNotificationCenter.defaultCenter() 监听 NSArrayController 中的项目选择的正确方法是什么

windows - windows 的 "notify-send"等效项是什么?

iphone - 远程通知 token 处理

android - 如何处理传递给 libc 的无效 pthread_t?

android - 我们如何在 O Developer Preview 2 中配置自动填充服务?

android - Flutter - 如何使用无代码设置连接到 Facebook 的 SDK 应用程序事件

android - 由于 FirebaseInstanceIdReceiver 中的 Intent { act=com.google.android.c2dm.intent.RECEIVE 广播而导致 ANR