Notification doesn't show up if only large icon is set

寵の児 提交于 2020-01-16 00:14:05

问题


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());

回答1:


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.



来源:https://stackoverflow.com/questions/29442092/notification-doesnt-show-up-if-only-large-icon-is-set

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!