【发布时间】:2019-05-10 03:02:32
【问题描述】:
我的应用适用于 API 26 或更高版本。
通知中的小图标有问题。 我去了这里的文档,不管我的问题是什么,我看到它提到图标必须是白色的,但是当我现在正在工作时,我正在使用谷歌播客应用程序收听播客,并且图标是彩色的。那么它必须是白色的吗?还是只有谷歌应用才有颜色?
文档链接: https://developer.android.com/guide/practices/ui_guidelines/icon_design_status_bar.html
我的问题是,当抽屉关闭时我的图标出现在顶部(它是彩色谷歌播客图标的绿色图标)。但是当drawe打开时,图标不显示,只是一个空白的绿色圆圈。
这就是我构建通知的方式:
Uri notificationSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(something, ADMIN_CHANNEL_ID)
.setSmallIcon(R.drawable.logo_fallback)
.setLargeIcon(resource)
.setContentTitle(remoteMessage.getData().get("title"))
.setContentText(remoteMessage.getData().get("message"))
.setAutoCancel(true)
.setSound(notificationSoundUri)
.setContentIntent(pendingIntent);
//Set notification color to match your app color template
notificationBuilder.setColor(getResources().getColor(R.color.colorPrimaryDark));
notificationManager.notify(notificationID, notificationBuilder.build());
我使用的资源是 PNG。我也尝试过 XML,但没有成功。
【问题讨论】:
标签: android push-notification notifications android-notifications android-notification-bar