android处理后台

时间:2018-01-16 18:23:25

标签: android firebase push-notification

我有一个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);

1 个答案:

答案 0 :(得分:0)

如果您收到通知消息,则当您的应用程序处于后台时,Firebase会自动处理这些消息 如果要在后台处理消息,那么它们应该具有数据有效负载。

选中此link