【发布时间】:2016-06-13 18:24:31
【问题描述】:
我的 Android 应用有一个小问题。它通过 FCM 接收通知并将其显示为推送通知。到目前为止一切正常,但奇怪的问题是,有时图标是白色的,有时是彩色的。
当应用程序在屏幕上打开并且此时我收到推送通知时,屏幕顶部会显示彩色的推送通知。
当应用程序关闭时,我会收到一个带有白色图标的推送通知。
我附上了截图: Screenshot
这里是创建推送通知的代码sn-p:
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());
我的移动设备是 Android 6.0.1,我的 SDK 版本是 23。
感谢您的帮助。
【问题讨论】:
标签: android android-notifications