【发布时间】:2017-06-11 04:39:47
【问题描述】:
我正在尝试使用 Glide 将图像加载到推送通知中,但它说:
FATAL EXCEPTION: Thread-9730
Process: com.monkingme.monkingmeapp, PID: 24226
java.lang.IllegalArgumentException: You must call this method on the main thread at com.bumptech.glide.util.Util.assertMainThread(Util.java:135)
以及使用的代码:
NotificationTarget notificationTarget = new NotificationTarget(
context,
rv,
R.id.remoteview_notification_icon,
notification,
NOTIFICATION_ID);
Glide.with(context.getApplicationContext())
.load(item.getString("cover_img"))
.asBitmap()
.placeholder(placeholder)
.error(placeholder)
.into(notificationTarget);
我正在使用 Aerogear 的 MessageHandler --> https://aerogear.org/docs/guides/aerogear-android/push/
问题是在推送通知中应用程序没有运行,所以没有主线程。有什么建议吗?
【问题讨论】:
-
这是个好问题
-
从 Glide 4.9.0 开始,在主线程外加载图像应该可以开箱即用! github.com/bumptech/glide/commit/…
标签: android notifications push android-glide remoteview