I’m getting image from the web when the image size is large i’m getting the following error
java.lang.OutOfMemoryError: bitmap size exceeds VM budget
My code is as follows i’m loading the image by using the LoadImageFromWebOperatins method.
animation.addFrame(LoadImageFromWebOperations(feed.getItem(i).getImage()), 2500);
animation.addFrame(LoadImageFromWebOperations(feed.getItem(i).getImage1()), 2500); animation.setOneShot(false);
iv.setBackgroundDrawable(animation);
iv.post(new Starter());
private Drawable LoadImageFromWebOperations(String url) {
try {
InputStream is = (InputStream) new URL(url).getContent();
Drawable d = Drawable.createFromStream(is, "src name");
return d;
} catch (Exception e) {
System.out.println("Exc=" + e);
return null;
}
}
In this case how do i solve this error? please provide solution for this.
I did something like this: