Guest User

HttpGet example

a guest
Sep 2nd, 2011
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.40 KB | None | 0 0
  1. TextView tv = (TextView) findViewById(R.id.test_calendar_textTV);
  2. HttpGet request = new HttpGet("http://www.google.com");
  3. try {
  4.     HttpResponse response = new DefaultHttpClient().execute(request);
  5.     if(response.getStatusLine().getStatusCode() == HttpStatus.SC_OK){
  6.         String result = EntityUtils.toString(response.getEntity());
  7.         tv.setText(result);
  8.     }
  9. } catch (IOException e) {
  10.     e.printStackTrace();
  11. }
Advertisement
Add Comment
Please, Sign In to add comment