如果仅设置大图标,则不会显示通知

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

我想在我的通知中添加一个大图标,但是当我 运行 应用程序时,通知没有显示。

当我换成小图标时,它可以工作,但图标太小了。

下面是我的代码,有什么地方不对吗?

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

根据 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 可能有助于构建合适的小图标。

在 Android 5.0+ 设备上,您可以使用 setColor() 为您的小图标设置品牌背景颜色。

大图标 不是 用于品牌推广目的 - 相反,它们应该用于 make it personal 并且是与通知发件人相关联的图像(即,个人资料图片)或其他信息以传达通知的含义。