-
Notifications
You must be signed in to change notification settings - Fork 6.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AppWidget/RemoteViews] IllegalArgumentException: You must call this method on the main thread #1363
Comments
The last #310 (comment) is still valid. You simply need to be on the main thread which has // prepare `glide` request builder
runOnUiThread({
// execute later
glide.into(new AppWidgetTarget(context, remoteViews, viewId, appWidgetId));
});
return remoteViews; Look into the If you know a better way, feel free to open a PR. |
Oh, you're right. I miss-interpreted that comment. BitmapRequestBuilder<ModelType, TranscodeType> glide = Glide.with(context)
.load(url)
.asBitmap()
.diskCacheStrategy(DiskCacheStrategy.ALL)
if (circleTransform) {
glide.transform(new CropCircleTransformation(context))
}
FutureTarget<TranscodeType> bitmap = it.into(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
remoteViews.setImageViewBitmap(viewId, bitmap.get())
Glide.clear(bitmap) But I have the following exception now:
|
Did you double-check that the Uri is correct and it exists? Glide can't do anything if you pass in invalid models, it only reads what you tell it. You probably had the same exception, but |
The URL is correct, because it works fine in the application itself. |
How to resole this problem? |
Glide Version: 3.7.0
Integration libraries:
Device/Android Version: Nexus 5 Emulator, Android 6.0 (with Google APIs)
Issue details / Repro steps / Use case background:
I am trying to use Glide to load an image from the network and display it inside an app widget.
To do so, I use an
AppWidgetTarget
as a parameter of theinto
method, but it ends up in a crash because the call is made on the wrongThread
.Glide load line /
GlideModule
(if any) / list Adapter code (if any):This code runs inside a
RemoteViewsFactory
, in thegetViewAt(int)
method.context
is the instance of theRemoteViewsService
, which created thisRemoteViewsFactory
remoteViews
is an instance of theRemoteViews
class, created in thegetViewAt(int)
methodviewId
is the id of the remoteImageView
that should display the loaded image.Stack trace / LogCat:
I found this issue, which looks similar to mine, but it's for an older version of
Glide
and I didn't find anything to help me there.The text was updated successfully, but these errors were encountered: