我的Android应用程序出现小问题。它通过FCM收到通知并将它们显示为推送通知。到目前为止,这一切都是有效的,但奇怪的问题是,有时图标是白色的,有时它是多彩的。Android通知图标颜色有时是白色的,有时是多彩的
当应用程序在屏幕上打开并且此时收到推送通知时,多彩推送通知会显示在屏幕顶部。
当应用程序关闭时,我收到带有白色图标的推送通知。
我附上一个screenhot: Screenshot
这里是代码片段,在其中创建推送通知:
Notification.Builder notificationBuilder = new Notification.Builder(this)
.setSmallIcon(android.R.drawable.ic_dialog_alert)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher))
.setAutoCancel(true)
.setVisibility(Notification.VISIBILITY_PUBLIC)
.setPriority(Notification.PRIORITY_HIGH)
.setColor(Color.parseColor("#83c3ed"))
.setLights(Color.RED, 1000, 500)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
Notification.InboxStyle inboxStyle = new Notification.InboxStyle();
inboxStyle.setBigContentTitle("WetterApp");
inboxStyle.addLine(notification.getTitle());
inboxStyle.addLine(notification.getBody());
notificationBuilder.setStyle(inboxStyle);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, notificationBuilder.build());
我的移动设备已经安卓6.0.1,我的SDK版本是23.
感谢您的帮助。
您应该在所有版本的Android上使用剪影 - 应用程序图标从来都不是正确的小图标。 – ianhanniballake
您至少应该提及您从http://stackoverflow.com/a/29207365/976367获得了答案 –