Android and Web Request (GET)

Android 2.2, Galaxy Tab, API Version 8

It’s easy with apache http client, see below code

//getResponse from any URL
private String getResponse(uRL) throws ClientProtocolException, IOException
String strRepsonse = “”;
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = httpclient.execute(new HttpGet(uRL));
StatusLine statusLine = response.getStatusLine();
if(statusLine.getStatusCode() == HttpStatus.SC_OK){
BufferedReader rd = new BufferedReader(new
String line = “”;
while ((line = rd.readLine()) != null) {
strRepsonse += line;
return strRepsonse;

I hope this is to the point 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.