2

I've created a simple notification using NotificationCompat.
Following is my code

NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mContext);
mBuilder.setSmallIcon(icon)
        .setTicker(title)
        .setWhen(0)
        .setAutoCancel(true)
        .setContentTitle(title)
        .setStyle(new NotificationCompat.InboxStyle())
        .setContentIntent(resultPendingIntent)
        .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
        .setContentText(message);

NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(mNotificationId, mBuilder.build());

Here is the output on my device.

enter image description here

My icon does not have the blue gradient background. The icon is a png that contains only the white USB symbol.
I'm suspecting that the background is being added by system.

Now my question is, how I can prevent this kind of modifications.

My device is running KitKat 4.4.4

Krishanu Dey
  • 6,326
  • 7
  • 51
  • 69

1 Answers1

2

If you do not specify a 'large' icon, the system displays the 'small' icon with a standard background, the blue gradient in your case.

You can set a custom image with setLargeIcon() where you can specify a Bitmap that is shown instead of the default icon. Note: The large icon should have a size of 64x64dp. Refer to this answer for a concrete example.

Since Android 5.0 you could alternatively use setColor() which will set the background color behind the icon. But that obviously won't work for you on Android 4.4.

Community
  • 1
  • 1
Floern
  • 33,559
  • 24
  • 104
  • 119