奥利奥通知图标不显示
Oreo Notification Icon not displaying
我使用了 targetSdkVersion 26 并且通知图标不显示。当我更改为 targetSdkVersion 20 时,它工作正常。但是,当我将应用程序上传到 Play 商店时,它并没有降级。如何在 targetSdkVersion 26 中显示图标。Notification small icon 72X72,
Notification home screen icon
这里我用的是图标大小
mipmap-mdpi : 24*24
mipmap-hdpi : 36*36
mipmap-xhdpi : 48*48
mipmap-xxhdpi : 72*72
并且我已将其存储到名为 logo_white.png
的 mipmap 中,因此在构建通知时您可以像
这样使用它
notificationBuilder.setSmallIcon(getNotificationIcon())...
notificationBuilder = new NotificationCompat.Builder(this, "default")
.setSmallIcon(icon)
.setContentTitle(getResources().getString(R.string.app_name))
.setStyle(new NotificationCompat.BigTextStyle().bigText(data.get("message")))
.setContentText(data.get("message"))
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimary))
.setContentIntent(pendingIntent)
.setPriority(Notification.PRIORITY_MAX);
这是方法
private int getNotificationIcon() {
boolean useWhiteIcon = (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP);
return useWhiteIcon ? R.mipmap.logo_white : R.mipmap.app_icon;
}
这里app_icon
是普通的应用程序图标,logo_white
是白色透明的应用程序图标
设置通知的简单方法你应该右键单击 drawable 或你的 mipmap 文件夹并选择图像资产并设置图标类型通知图标并选择你的透明图像通知。
谢谢。
我使用了 targetSdkVersion 26 并且通知图标不显示。当我更改为 targetSdkVersion 20 时,它工作正常。但是,当我将应用程序上传到 Play 商店时,它并没有降级。如何在 targetSdkVersion 26 中显示图标。Notification small icon 72X72, Notification home screen icon
这里我用的是图标大小
mipmap-mdpi : 24*24
mipmap-hdpi : 36*36
mipmap-xhdpi : 48*48
mipmap-xxhdpi : 72*72
并且我已将其存储到名为 logo_white.png
的 mipmap 中,因此在构建通知时您可以像
notificationBuilder.setSmallIcon(getNotificationIcon())...
notificationBuilder = new NotificationCompat.Builder(this, "default")
.setSmallIcon(icon)
.setContentTitle(getResources().getString(R.string.app_name))
.setStyle(new NotificationCompat.BigTextStyle().bigText(data.get("message")))
.setContentText(data.get("message"))
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimary))
.setContentIntent(pendingIntent)
.setPriority(Notification.PRIORITY_MAX);
这是方法
private int getNotificationIcon() {
boolean useWhiteIcon = (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP);
return useWhiteIcon ? R.mipmap.logo_white : R.mipmap.app_icon;
}
这里app_icon
是普通的应用程序图标,logo_white
是白色透明的应用程序图标
设置通知的简单方法你应该右键单击 drawable 或你的 mipmap 文件夹并选择图像资产并设置图标类型通知图标并选择你的透明图像通知。
谢谢。