Java 为ForegroundService定义为“setSmallIcon(R.mipmap.ic_launcher)”时,通知没有图标

Java 为ForegroundService定义为“setSmallIcon(R.mipmap.ic_launcher)”时,通知没有图标,java,android,android-notifications,foreground-service,Java,Android,Android Notifications,Foreground Service,我正在为Android上的ForegroundService生成通知,但我的图标未显示: return new NotificationCompat.Builder(this, CHANNEL_ID) .setContentText("Sdílení polohy je aktivní") .setSmallIcon(R.mipmap.ic_launcher) .setLargeIcon(Bitmap

我正在为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文件夹放在透明背景上。除白色外,您不使用任何颜色

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

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

它需要是白色的,即使只是通知?因为有些应用程序有彩色图标,所以你可以查看材质设计。只有一套颜色。