I want to shows the images in imageview from an array list,the array containing a list of URL like
private String imageUrls[] = {"http://theopentutorials.com/totwp331/wp-content/uploads/totlogo.png",
"http://theopentutorials.com/totwp331/wp-content/uploads/totlogo.png",
"http://theopentutorials.com/totwp331/wp-content/uploads/totlogo.png"
};
When i go to next image it shows it shows the OutOfMemoryException
.
Please help
I used the code as follows
protected Bitmap doInBackground(String... urls) {
Bitmap bitmap = null;
try {
String url = urls[0];
InputStream in = null;
try {
in = new java.net.URL(url).openStream();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
bitmap = BitmapFactory.decodeStream(in);
} catch (OutOfMemoryError e) {
Log.e("MyApp", e.getMessage());
}
return bitmap;
}
protected void onPostExecute(final Bitmap result) {
handler=new Handler();
handler.post(new Runnable() {
@Override
public void run() {
bmImage.setImageBitmap(result);
}
});
}