Download Bitmap return nulls sometimes
<p>I have some code that retrieves an image from the web using this method</p>

<pre><code>public  Bitmap downloadFile(String fileUrl){
    URL myFileUrl =null;          
    try {
        myFileUrl= new URL(fileUrl);
    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    try {
        HttpURLConnection conn= (HttpURLConnection)myFileUrl.openConnection();
        conn.setDoInput(true);
        conn.setReadTimeout(500000000);
        conn.connect();
        InputStream is = conn.getInputStream();
        BitmapFactory.Options options=new BitmapFactory.Options();
        options.inSampleSize = 8;

        return BitmapFactory.decodeStream(is,null,options);

    } catch (IOException e) {
        Log.e("log_tag", " Download image failed"+e.getMessage());
        e.printStackTrace();
    }
    return null;
}
</code></pre>

<p>However, sometimes it returns null with no error, and sometimes it works.</p>

<p>I tried setting the timeout to a large number and it still doesn't have an error. </p>
