Skip to content

Instantly share code, notes, and snippets.

@dineshr93
Created September 1, 2015 13:02
Show Gist options
  • Select an option

  • Save dineshr93/5457933c553fced07cb3 to your computer and use it in GitHub Desktop.

Select an option

Save dineshr93/5457933c553fced07cb3 to your computer and use it in GitHub Desktop.
package com.hanselandpetal.catalog;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.util.EntityUtils;
import android.net.http.AndroidHttpClient;
public class HttpManager {
public static String getData(String uri) {
AndroidHttpClient client = AndroidHttpClient.newInstance("AndroidAgent");
HttpGet request = new HttpGet(uri);
HttpResponse response;
try {
response = client.execute(request);
return EntityUtils.toString(response.getEntity());
} catch (Exception e) {
e.printStackTrace();
return null;
} finally {
client.close();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment