1

I want to add a large icon to my notification, but when I run the app, the notification doesn't show up.

When I change to small icon, it works but icon is too small.

Below is my code, any help where it is wrong?

Bitmap rawBitmap = BitmapFactory.decodeResource(getResources(),
                                                     R.drawable.ic_launcher);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
    .setLargeIcon(rawBitmap)
    .setContentTitle("Alert")
    .setContentText("CITRUS PUNCH Minute Maid expired");
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(1, mBuilder.build());
Sufian
  • 6,405
  • 16
  • 66
  • 120
michael
  • 397
  • 4
  • 12
  • try to add both SetStyle and SetPriorityas as the following : .SetStyle(new Notification.BigTextStyle().BigText(message.Long_Message)) .SetPriority((int)NotificationPriority.Max) – Mohamad Mahmoud Darwish Feb 07 '17 at 19:08

1 Answers1

4

Per the notification guide list of required fields, you must set a small icon via the setSmallIcon() method. Generally, this icon looks like your application icon, although entirely as white over a transparent background per the notification iconography guide: tools such as the Notification Icon Generator may help in building an appropriate small icon.

On Android 5.0+ devices, you can use setColor() to set a branded background color for behind your small icon.

Large icons are not meant for branding purposes - instead, they should be used to make it personal and be an image associated with the sender of the notification (i.e., a profile picture) or additional information to convey the meaning of the notification.

ianhanniballake
  • 191,609
  • 30
  • 470
  • 443
  • I was having a similar issue and ended up not using the large icon because of the same error. Do you mean to say that the large icon is not meant be used for just showing a notification? – Msk Apr 04 '15 at 05:36
  • Right, you're much better off not using a large icon if all you are going use it for is your launcher icon: that will almost never look quite right due to how notifications are displayed – ianhanniballake Apr 04 '15 at 05:38
  • Thanks this will stop a lot of waste of time in trying to make the large icon work:-) – Msk Apr 04 '15 at 05:41