I want to load the Arwork-Image into my Notification (with MediaStyle
).
Using the following code crashes my app with the error:
java.lang.IllegalArgumentException: You must call this method on a background thread
public Bitmap getAlbumArtwork(long albumID, int Height, int Width) {
try {
return Glide.with(mContext).load(getAlbumArtworkUri(albumID)).asBitmap().error(R.drawable.standardartwork).into(Width, Height).get();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
return null;
}
I'm also willing to change the library, e.g. to UniversalImageLoader
, if necessary!
Additionally
I use this method to load the image for a notification... This notification is created in a service, so the ui will not be interrupted! As i have no ID of the notifications ImageView, I don't know how to set it in another way! Furthermore I need the Bitmap to add it to the MediaMetaData for the MediaSession.