How can I read an image from a URL in Android?
<p>I want to read an image from a this URL <a href="http://184.173.7.132/RealAds_Images/Apartment%20for%20sale,%20Sheikh%20Zayed%20_%201.jpg" rel="nofollow">photo</a></p>

<p>and I'm using the following code </p>

<pre><code> public static Bitmap DownloadImage(String URL)
{
    Bitmap bitmap=null;
    InputStream in=null;
    try {
        in=networking.OpenHttpConnection("http://izwaj.com/"+URL);
        BitmapFactory.Options options=new BitmapFactory.Options();
        options.inSampleSize=8;

        bitmap=BitmapFactory.decodeStream(in, null, options);
        in.close();
    } catch (Exception e) {
        // TODO: handle exception
    }
    return bitmap;
}

 public class Networking {
public InputStream OpenHttpConnection(String urlString)

        throws IOException
        {
    InputStream in=null;
    int response = -1;

    URL url=new URL(urlString);
    URLConnection conn=url.openConnection();

    if(!(conn instanceof HttpURLConnection))
    {
        throw new IOException("Not an HTTP connection");
    }

    try {
        HttpURLConnection httpconn=(HttpURLConnection)conn;
        httpconn.setAllowUserInteraction(false);
        httpconn.setInstanceFollowRedirects(true);
        httpconn.setRequestMethod("GET");
        httpconn.connect();
        response=httpconn.getResponseCode();
        if(response==HttpURLConnection.HTTP_OK)
        {
            in=httpconn.getInputStream();
        }
    }



    catch (Exception ex) {
        throw new IOException("Error connecting");
    }
    return in;

        }
</code></pre>

<p>The bitmap always returned to me null.. I used also other functions found on the internet. all returned the bitmap as null value :S</p>
