为 ForegroundService 定义为 `setSmallIcon(R.mipmap.ic_launcher)` 时通知没有图标

Notification not have icon when defining as `setSmallIcon(R.mipmap.ic_launcher)` for ForegroundService

我正在 Android 上为我的 ForegroundService 构建通知,但我的图标没有显示:

return new NotificationCompat.Builder(this, CHANNEL_ID)
                .setContentText("Sdílení polohy je aktivní")
                .setSmallIcon(R.mipmap.ic_launcher)
                .setLargeIcon(BitmapFactory.decodeResource(this.getResources(), R.mipmap.ic_launcher))
                .build();

我做错了什么?

创建一个仅使用白色的图标集,并将 mipmap 文件夹放在透明的 background.You 上,不要使用白色以外的任何颜色。 Icon generator

并将此代码用于图标色调:

 .setSmallIcon(R.mipmap.notification_icon)
 .setColor(ContextCompat.getColor(context, R.color.yourColor))