-1

In Redmi Note 5 Pro, I am using remoteviews for custom notifications. While doing this, the resource which i am passing using setsmallicon() is not being taken and plain solid square is being displayed. The resource is being used if it is not a custom notification.

Can someone help me solve this issue.

2 Answers2

0

From android version lollpop onwards, they have made the changes for the notifications. When you are specifing the small icon, it should be of specific size as mentioned in this link.

The important thing is the image should be transparent and contains only white color.

Try using single color white with transparent background png file and add your icon in mipmap folder and your problem solved.

Masoud Mokhtari
  • 2,390
  • 1
  • 17
  • 45
  • Yes, I have done all of these. This issue is specific to the mentioned device and custom notification. The working is as expected if the notification is not custom. – Johnson Rose Dec 12 '18 at 13:04
0

You need to add meta data in manifest with icon like this:

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

and you have to use same notification_icon icon as setSmallIcon with NotificationCompat.Builder like this:

 NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, channelId)
                .setSmallIcon(R.drawable.notification_icon)
                .setLargeIcon(myBitmap)
                .setContentTitle(notification.getTitle())
                .setContentText(notification.getBody())
                .setAutoCancel(true)
                .setSound(defaultSoundUri)
                .setContentIntent(pendingIntent);
Dhvani023
  • 877
  • 5
  • 8