Setting small icon in Notification above lollipop version
Asked Answered
D

1

8

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. enter image description here

Anybody please help me...

Below is the Notification Im getting.

enter image description here

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??

Dolorisdolorita answered 17/6, 2020 at 6:47 Comment(2)
Could you share screen shot of what you are getting output for above code.Goulash
@SrinivasanM I have added my screenshot.Dolorisdolorita
E
0

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

Earthworm answered 27/6, 2020 at 16:37 Comment(5)
already seen that but I want to set two different color. In my icon need to set different color for h and mDolorisdolorita
@Dolorisdolorita did you manage to fix this issue ?Easterner
@SethuramanSrinivasan No. I could not able to achieve multiple color in small icon. So I just used only one color.Dolorisdolorita
@Dolorisdolorita I am also stuck in this issue.Pluperfect
@Pluperfect I couldn't find solution for this issue. Instead I used a single icon with one color.Dolorisdolorita

© 2022 - 2024 — McMap. All rights reserved.