I am using the UrlImageViewHelper lib developed by Koushik Dutta (Koush). Here is what I am doing
- Load images from a url into imageview which are inside a gridview.
- Image loading works perfectly and is quite fast.
I am trying to save the image loaded inside the imageview, as a wallpaper but it crashes and throws up a casting exception.
The code
UrlViewImageHelper.setURLDrawable(imageView,"some url here");
Bitmap bitmap = ((BitmapDrawable)imageView.getDrawable()).getBitmap();
The above line throws this exception
02-26 06:54:07.987: E/AndroidRuntime(19659): java.lang.ClassCastException: com.koushikdutta.urlimageviewhelper.UrlImageViewHelper$ZombieDrawable
How do I get the image inside the imageView as a bitmap? What am I doing wrong?
I understand that I can use some other library such as Android Universal Image Loader (have not tried it yet),SmartImageView (good but slow), but koush's library is quite fast and simple to use.
URLViewImageHelper downloads the image in separate thread asynchronously, hence at the point you call imageView.getDrawable(), the image not loaded yet.
What u can try is to register a callback object to be notified when image finished loading: