我已经创建了抬头通知。就像下面这样,
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))
但使用它只能设置一种独特的颜色。
**我的目标不是那个。我想将我的图标设置为其原始颜色,就像多米诺骨牌一样。
在 Android Manifest 中添加以下代码,
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/notification_icon" />
当我收到推送通知时,我正在启动我的服务来显示通知,如下所示,
startService(new Intent(this,NotificationService.class));
But Im getting notification icon with grey color, not in original color.
Also searched a lot sites and stack question. But the answer for the question regarding this problem is the code for placing notification icon in Android Manifest which I mentioned above. Eventhough I followed the answers, couldn't set the notification icon as like dominos.
I didnt able to find where it is going wrong.
Searched most of the stack questions posted. But not able to find suitable answer for my problem.
任何人请帮助我...
以下是我收到的通知。
如您所见,我的通知图标由两个文本组成。这两个包含两种不同的颜色。这就是我想要实现的目标。但我只得到灰色。设置颜色只会为 h 和 m 设置一种唯一的颜色。我不想那样。
这个没有办法解决吗??没有人做到这一点吗??