繁体   English   中英

Android通知-小图标在某些设备上不起作用

[英]Android Notification - Small icon not working on some devices

根据https://developer.android.com/training/notify-user/build-notification#java,我正在正确创建通知。

我期望的是:

在此处输入图片说明

我的代码是:

NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, "channel")
                .setSmallIcon(R.drawable.wesay_not)
                .setContentTitle(notification.title)
                .setContentText(notification.description)
                .setAutoCancel(true)
                .setSound(defaultSoundUri)
                .setContentIntent(pendingIntent)
                .setChannelId(context.getString(R.string.channel_id));

可绘制对象在那里:

在此处输入图片说明

但是设备显示的是默认的Android设备,其他应用程序似乎显示的是ok图标:

在此处输入图片说明

您正在使用的设备可能是xxxhdpi 并以某种方式使用这些设备的默认图标。

如果不使用默认图标,建议您将其从项目中删除。 而且,您可以使用Notification Icon Generator来生成所有大小的图标。

啊,我刚刚注意到XXHDPI图标是128x128,应该是72x72,这可能与

首先在整个项目中找到名为“ wesay_not”的默认图标。 如果找到,则将其替换为具有文件夹相关大小的实际图标。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM