如何为应用程序及其通知设置不同的图标?

How to set different icons for app and for its notifications?

我使用黑色背景和白色标志的图片作为我的应用程序的图标。问题是当我收到通知时,显示屏顶部的图标完全是白色的(老实说,我不知道为什么,当屏幕锁定时它看起来像原来一样)。

我想通过为通知设置不同的图标来解决这个问题,我可以使用 this site,当我使用这个网站生成的文本图标时它工作得很好。

我想知道如何为我的应用程序及其通知设置不同的图标,我知道这是可能的,但我只有同时用于应用程序和通知图标的文件夹 (drawable-[hdpi/mdpi/xhdpi/xxhdpi/xxxhdpi] ).

The problem is when I'm getting a notification a icon at the top of the display is completely white (I don't know why to be honest, when screen is locked it looks as originally).

您在 Notification.Builder 中设置了 SetSmallIcon()。

理解Android文档如下-“更新或删除涉及颜色的资产。系统会忽略操作图标和主通知图标中的所有 non-alpha 个频道。您应该假定这些图标将是 alpha-only。系统以白色绘制通知图标,以深灰色绘制操作图标。”

只需点击几下,您就可以将通知图标转换为 Android 友好图标。

Notification icon generator 中,打开您的图标文件。将您不想显示的图像的所有部分转换为透明像素。所有颜色和非透明像素都显示为白色。

问题解决了,我在下面添加到AndroidManifest.xml(应用部分)

<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/new_notification_icon" />