我的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獲得了答案 –