Ich erhalte Daten mit fcm und ich möchte eine Benachrichtigung erstellen, die ein Bild enthält. Wenn ich diese Daten bekomme, bekomme ich die URL des Bildes, das ich versuche glide zu laden, glide aber ablehnt aus dem Dienst [FirebaseMessagingService]Ich kann keine Benachrichtigung mit Glide erstellen
public class MyFirebaseMessagingService extends FirebaseMessagingService {
private final String TAG = getClass().getName();
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
try {
if (remoteMessage.getData().containsKey("notification")) {
Gson gson = new Gson();
Notif notif = gson.fromJson(remoteMessage.getData().get("notification"), Notif.class);
politicoDataRepository.getPolitico(notif.getPolitico_id())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(politico -> {
createNotifiation(notif, getApplicationContext());
}, throwable -> Log.e("Error", throwable.getMessage() + " " + TAG));
} else {
Log.i("datFirebase", remoteMessage.getFrom() + " " + remoteMessage.getData().get("id"));
}
} catch (Exception e) {
e.printStackTrace();
} finally {
realm.close();
}
}
private void createNotifiation(Notif notif, Context context) {
final RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.notification_item);
remoteViews.setImageViewResource(R.id.notif_image, R.mipmap.ic_launcher);
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle(notif.getTitle())
.setContentText(notif.getMessage())
.setContent(remoteViews)
.setPriority(NotificationCompat.PRIORITY_MIN);
final Notification notification = mBuilder.build();
if (android.os.Build.VERSION.SDK_INT >= 16) {
mBuilder.setCustomBigContentView(remoteViews);
}
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(141, notification);
NotificationTarget notificationTarget = new NotificationTarget(this, remoteViews, R.id.notif_image, notification, 141);
Glide.with(this)
.load(notif.getImage())
.asBitmap()
.into(notificationTarget);
}
}
Bitte fügen Sie log, -Code korrekt geschrieben. –
Die einzige Ausgabe, die ich bekomme, ist notif.getId() und notif.getimage(), ich bekomme keine Ausgabe vom Gleitteil. –
Fügen Sie den Code hinzu, von dem aus Sie die createNotifiation-Methode aufrufen. –