Here you can find the source of loadImage(String urlStr)
public static Bitmap loadImage(String urlStr)
//package com.java2s; import java.io.IOException; import java.io.InputStream; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.params.HttpConnectionParams; import org.apache.http.params.HttpParams; import android.graphics.Bitmap; import android.graphics.BitmapFactory; public class Main { public static Bitmap loadImage(String urlStr) { Bitmap bm = null;/*from w ww . ja va 2 s. c o m*/ HttpClient httpclient = new DefaultHttpClient(); HttpParams params = httpclient.getParams(); HttpConnectionParams.setConnectionTimeout(params, 1000 * 5); HttpConnectionParams.setSoTimeout(params, 1000 * 5); HttpGet httpGet = new HttpGet(urlStr); try { HttpResponse httpResponse = httpclient.execute(httpGet); HttpEntity entity = httpResponse.getEntity(); InputStream is = entity.getContent(); bm = BitmapFactory.decodeStream(is); is.close(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return bm; } }