Q:

How to download images not from directed URL

With Android Studio I want to download the images from a URL , I mean that these images are in this URL. I have the code but it's for direct download of them.
I must show them in a Custom ListView.
This is the code:
ImageView img = (ImageView) rowView.findViewById(R.id.enclosure);
    try {
        URL url = new URL("MY_URL"); <-- the URL where I want to get the images in enclosures
        HttpGet httpRequest = null;

        httpRequest = new HttpGet(url.toURI());

        HttpClient httpclient = new DefaultHttpClient();
        HttpResponse response = (HttpResponse) httpclient
                .execute(httpRequest);

        HttpEntity entity = response.getEntity();
        BufferedHttpEntity b_entity = new BufferedHttpEntity(entity);
        InputStream input = b_entity.getContent();

        Bitmap bitmap = BitmapFactory.decodeStream(input);

        img.setImageBitmap(bitmap);

    } catch (Exception ex) {

    }

Before I had this:
ImageView img = (ImageView) rowView.findViewById(R.id.enclosure);
img.setImageDrawable(web.get(position).getEnclosure());

but the images weren't displayed.

A:

As far as I can tell, this is trying to decode the input stream of the entire page, which wouldn't work because the page is not just an image; there is text and such as well. This wouldn't work. You have to get the URL of each of the images you want to download, and then download those images separately.

