I'm using glide to load an image using its resource ID into a bitmap, and I want to pass the bitmap to a member function of a custom view class.
This is my code:
try {
Bitmap bm=Glide.
with(getApplicationContext()).
load(mThumbIds[position]).
asBitmap().
into(width, height). // Width and height
get();
drawView.setImg(bm);
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
Whenever I try to run it I get the following error:
Unable to start activity ComponentInfo{...}: java.lang.IllegalArgumentException: YOu must call this method on a background thread
How do I fix this?