Skip to content

Instantly share code, notes, and snippets.

@mattapayne
Created April 19, 2009 20:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattapayne/98205 to your computer and use it in GitHub Desktop.
Save mattapayne/98205 to your computer and use it in GitHub Desktop.
1. private String get(String url, Map params)
2. {
3. String result = null;
4. try
5. {
6. String queryString = getEncodedQueryString(params);
7. String fullUrl = url + "?" + queryString;
8. DefaultHttpClient client = new DefaultHttpClient();
9. HttpGet method = new HttpGet(new URI(fullUrl));
10. HttpResponse response = client.execute(method);
11. if(response.getStatusLine().getStatusCode() == HttpStatus.SC_OK)
12. {
13. HttpEntity e = response.getEntity();
14. if(e != null)
15. {
16. result = convertStreamToString(e.getContent());
17. }
18. }
19. }
20. catch(Exception e)
21. {
22. Log.e("Error", "An error occurred: " + e.getMessage());
23. }
24. return result;
25. }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment