I am facing problems while downloading images from array of urls to show list of images. I am storing image urls into one array and when i iterate this array i am calling a method to download and return a bitmap by passing one url at one time. But after completing this iteration i am missing some images. That means i came to know that the iteration process skipping some images.
Can any one help me in this? For reference purpose i am attaching my code here, which I am running in separate thread with handler.
Bitmap[] data = new Bitmap[urls.size()];
for (int i = 0; i < urls.size(); i++) {
Bitmap temp=getBitmapFromURL(urls.get(i));
if(temp!=null){
data[i] = temp;
}
}
public static Bitmap getBitmapFromURL(String urlString) {
try {
URL url = new URL(urlString);
InputStream input = url.openConnection().getInputStream();
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 8;
myBitmap = BitmapFactory.decodeStream(input, null, options);
return myBitmap;
}catch (Exception e) {
e.printStackTrace();
}
}