0

根据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));

并且drawable在那里:

在此处输入图像描述

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

在此处输入图像描述

4

3 回答 3

2

您正在使用的设备可能是xxxhdpi. 并且不知何故它正在为这些设备采用默认图标。

如果您不使用它,我建议您从项目中删除默认图标。您可以使用通知图标生成器生成所有大小的图标。

于 2019-02-22T06:35:33.653 回答
0

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

于 2019-02-22T06:19:50.917 回答
0

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

于 2019-02-22T06:30:15.063 回答