Question

I'm developing an Android application, and it's view is containing multiple Gallerys. The content of the Gallerys (the Bitmaps) are red from the Internet.

For the first gallery, everything works fine, but when trying to download the first image of the second Gallery, the BitmapFactory.decodeStream(InputStream) returns null, while the stream is NOT null.

public void loadBitmap() throws IOException {

        for (int i = 0; i < images.size(); ++i) {
            URL ulrn = new URL(images.get(i).getThumbUrl());
            HttpURLConnection con = (HttpURLConnection) ulrn.openConnection();
            InputStream is = con.getInputStream();
            images.get(i).setImage(BitmapFactory.decodeStream(is));
            Log.i("MY_TAG", "Height: " + images.get(i).getImage().getHeight());
        }
}

The getThumbUrl() returns the URL of the image (eg. http://mydomain.com/image.jpg) and it throws a NullPointerException at the line Log.i("MY_TAG", "Height: ... ) (images is an ArrayList containing objects of my class, that holds the URL and the Bitmap too).

Thanks for any advice!

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top