Simple HTTP Request
package app.test; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; import android.app.Activity; import android.os.Bundle; import android.util.Log; public class Test extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); HttpClient httpclient = new DefaultHttpClient(); HttpGet httpget = new HttpGet("http://java2s.com"); try { HttpResponse response = httpclient.execute(httpget); HttpEntity entity = response.getEntity(); if (entity != null) { InputStream inputstream = entity.getContent(); BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(inputstream)); StringBuilder stringbuilder = new StringBuilder(); String currentline = null; while ((currentline = bufferedreader.readLine()) != null) { stringbuilder.append(currentline + "\n"); } String result = stringbuilder.toString(); Log.v("HTTP REQUEST",result); inputstream.close(); } } catch (Exception e) { e.printStackTrace(); } } }