我有一个Android应用程序,我试图在通知中添加大图 我的问题是,当应用处于前台时,大图片正在工作但是当应用处于后台或关闭时,收到的通知没有图片。
我的代码:
intentNotification.addFlags(android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP);
intentNotification.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 50, intentNotification, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this.getApplicationContext())
.setContentTitle(dataTitle)
.setContentText(dataBody)
//.setLargeIcon(getBitmapicon(getApplicationContext()))
.setSmallIcon(getNotificationIcon())
//.setLargeIcon(icon(getApplicationContext()))
.setStyle(new NotificationCompat.BigPictureStyle()
.bigPicture(image))
.setLights(Color.LTGRAY, 1000, 1000)
.setAutoCancel(true)
.setTicker(dataTitle)
.setContentIntent(pendingIntent)
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
Notification notification = notificationBuilder.build();
notification.flags = notification.flags | Notification.FLAG_SHOW_LIGHTS;
nManager.notify((int) SystemClock.currentThreadTimeMillis(), notification);