android - 在棒棒糖版本上方的通知中设置小图标
问题描述
我已经创建了抬头通知。如下所示,
NotificationCompat.Builder notification = new NotificationCompat.Builder(this, channelId)
.setContentTitle("Message")
.setContentText("Recieved Successfully")
.setContentIntent(pendingIntent)
//.setColor(ContextCompat.getColor(this, R.color.green))
.setSmallIcon(R.drawable.notification_icon)
.setDefaults(Notification.DEFAULT_ALL)
.setContentIntent(pendingIntent)
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
.setAutoCancel(true)
.setPriority(NotificationCompat.PRIORITY_HIGH);
manager.notify(m,notification.build());
上面的代码放在一个名为 NotificationService 的类中,该类扩展了 Service。
我可以使用下面的代码设置颜色,
setColor(ContextCompat.getColor(this, R.color.colorAccent))
但是使用它只能设置一个独特的颜色。
**我的目标不是那样。我想将我的图标设置为其原始颜色,就像在 Dominos 中一样。
在 Android Manifest 中添加了以下代码,
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/notification_icon" />
当我收到推送通知时,我正在启动我的服务以显示如下通知, startService(new Intent(this,NotificationService.class));
但我收到灰色通知图标,而不是原始颜色。还搜索了很多网站和堆栈问题。但是关于这个问题的问题的答案是我上面提到的在 Android Manifest 中放置通知图标的代码。尽管我遵循了答案,但无法将通知图标设置为多米诺骨牌。我没能找到哪里出错了。搜索了大多数发布的堆栈问题。但无法为我的问题找到合适的答案。
任何人请帮助我...
以下是我收到的通知。
如您所见,我的通知图标由两个文本组成。而这两个包含两种不同的颜色。这就是我想要达到的目标。但我只得到灰色。设置颜色将为 h 和 m 设置一种唯一的颜色。我不想要那个。
这个没有解决办法??没有人做到这一点??
解决方案
推荐阅读
- mysql - RAND() 是否具有低熵来生成盐?
- node.js - 是否可以在运行时向 Node.js 信任库添加证书颁发机构?
- react-native - 如何更改或设置 React Native 中“rightcircle”图标内的箭头?
- javascript - 为什么我无法显示图像(base64 字符串)
- javascript - 以最快的方式使用另一个列表过滤一个列表?
- python - 如何将简单 ITK 图像的所有像素乘以一个标量?
- javascript - 如何在下方弹出手风琴常见问题解答?
- html - 如何使用 CSS 创建此布局?
- sql - 在 PGadmin4 中创建表时出现逗号抛出错误
- java - 如何使用 Java 对数据库(NoSQL 和 SQL)进行基准测试