通知图标在 Nougat 中显示为 Square

Posted

技术标签:

【中文标题】通知图标在 Nougat 中显示为 Square【英文标题】:Notification icon display as Square in Nougat 【发布时间】:2017-09-11 07:27:38 【问题描述】:

您好,我已经在我的应用程序中实现了推送通知。 对于牛轧糖版本以下的设备,它工作正常并正确显示通知图标。

但是,它显示通知图标为方形,颜色为白色。

下面是我的代码:

Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
            NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
                    .setSmallIcon(R.mipmap.app_icon)
                    .setColor(ContextCompat.getColor(getApplicationContext(),R.color.white))
                    .setContentTitle(strTitle)
                    .setContentText(messageBody)
                    .setAutoCancel(true)
                    .setSound(defaultSoundUri)
                    .setContentIntent(pendingIntent);

            NotificationManager notificationManager =
                    (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

            notificationManager.notify(++NOTIFICATION_ID /* ID of notification */, notificationBuilder.build());

【问题讨论】:

【参考方案1】:

首先,这不是错误。这是 android Nougat 的设计变化

对于 Android Nougat,您应该为通知提供圆形图标。 查看 this 链接和this了解更多详情。

【讨论】:

以上是关于通知图标在 Nougat 中显示为 Square的主要内容,如果未能解决你的问题,请参考以下文章