android - Android 推送通知图标 LIght 主题问题
问题描述
我知道这个问题被问了很多次与推送通知状态栏图标有关,但我的问题有点不同。
我正在使用 FCM 推送通知,我的通知正常发送。我已经为 pre-lollipop 和更多的棒棒糖版本设置了通知图标。我的通知图标在 MOTO-G 5+ 等深色主题设备中正常显示,但是当我在三星 Galaxy Edge 7.0 等浅色主题设备上查看相同通知时,我的通知图标根据应用主题变为白色,但在另一个应用中,通知图标看起来正常。我看到了许多示例解决方案,但它们对我的问题没有帮助。
我正在使用以下代码:
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ila_app_icon);
long when = System.currentTimeMillis();
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this);
notificationBuilder.setContentText(message)
.setContentIntent(pendingIntent)
// .setColor(getNotificationColor())
.setSmallIcon(getNotificationIcon(notificationBuilder))
.setWhen(when)
.setSound(defaultSoundUri)
.setLargeIcon(bitmap);
Random random = new Random();
int uniqueIntegerNumber = random.nextInt(9999 - 1000) + 1000;
notificationManager.notify(uniqueIntegerNumber, notificationBuilder.build());
获取通知图标方法:-
private int getNotificationIcon(NotificationCompat.Builder notificationBuilder) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
int color = 0x008000;
notificationBuilder.setColor(color);
return R.drawable.notification_white;
}
return R.drawable.ila_app_icon;
}
我也尝试了setColor属性,但这也不起作用。
1)轻主题 (这里是白旗图标)
2)黑暗主题:-
解决方案
经过所有搜索和其他事情后,我找到了我的解决方案,一切正常,除了通知图标,图标保持着不同颜色的一点点像素。
我们可以从以下链接创建通知图标,它使我们的图标对通知透明
推荐阅读
- java - Prisma 易受攻击的依赖项未显示在 Maven 依赖项中:树
- arrays - Powershell自动填充数组
- sql - 如果变量为空,则插入默认值
- android - 将硬件键盘连接到 android 时禁用指定键
- git - Git 在拉取请求时排除文件
- javascript - 如何使用“ngFor”而不重复应用它的元素?
- android - 如何在 PWA 对话框中检测安装点击事件?
- javascript - 如何一次只监听一个事件并在javascript中关闭其他监听器>
- python - 生成文件的 MD5 哈希值并与导入 txt 文件中的 MD5 哈希值进行比较
- macos - Scilab csvRead 找不到文件