问题
I have created heads up notification. As like below,
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());
Above code placed inside a class named NotificationService which extends Service.
I can able to set color using below code,
setColor(ContextCompat.getColor(this, R.color.colorAccent))
But using that able to set only a unique color.
**My goal is not that.I want to set my icon with its original color as like in Dominos.
Added below code in Android Manifest,
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/notification_icon" />
When I am getting push notification I am starting my Service for displaying notification like below, 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.
Anybody please help me...
Below is the Notification Im getting.
As you can see my notification icon consist of two text. And those two contains two different color. Thats what I am trying to achieve. But I am getting only grey color. Setting color will set only one unique color for both h and m. I dont want that.
There is no solution for this?? No one achieved this??
回答1:
In the new Android SDKs I think all icons are turned into a plain color.
Look into this question that provides some solutions in notification colors in Lollipop.
Notification bar icon turns white in Android 5 Lollipop
来源:https://stackoverflow.com/questions/62422988/setting-small-icon-in-notification-above-lollipop-version