我正在跟随android开发人员文档创建一个包含一个图像的可扩展通知。我已经按照docs编写了相同的代码,但是在我扩展通知后我的大图标没有隐藏。 这是我的代码:-
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, id)
.setSmallIcon(getNotificationIcon())
.setColor(ContextCompat.getColor(this, R.color.colorPrimary))
.setContentTitle(title)
.setContentText(data.get("message"))
.setLargeIcon(bitmap)
.setStyle(new NotificationCompat.BigPictureStyle().bigPicture(bitmap)
.bigLargeIcon(null))
.setAutoCancel(true).setChannelId(id)
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
Notification notification = notificationBuilder.build();
notification.sound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
notification.flags |=
Notification.FLAG_AUTO_CANCEL; //Do not clear the notification
notification.defaults |= Notification.DEFAULT_LIGHTS; // LED
notification.defaults |= Notification.DEFAULT_VIBRATE;//Vibration
notificationManager.notify(mUniqueId, notification);
和android开发人员的代码:-
Notification notification = new NotificationCompat.Builder(mContext, CHANNEL_ID)
.setSmallIcon(R.drawable.new_post)
.setContentTitle(imageTitle)
.setContentText(imageDescription)
.setLargeIcon(myBitmap)
.setStyle(new NotificationCompat.BigPictureStyle()
.bigPicture(myBitmap)
.bigLargeIcon(null))
.build();
我无法理解我是否缺少某些东西或做错了什么。请帮忙 。预先谢谢你。
答案 0 :(得分:0)
我得到了答案! 实际上,这是特定于设备的问题。某些android设备并未在扩展通知时隐藏大图标,而有些设备则将其隐藏。