Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. HttpGet httpRequest = new HttpGet(myUri);
  2. HttpClient httpclient = new DefaultHttpClient();
  3. HttpResponse response = httpclient.execute(httpRequest);
  4. response.getStatusLine().getStatusCode(); // Your status-code
  5.  
  6. HttpGet get = new HttpGet(url);
  7. HttpClient httpclient = new DefaultHttpClient();
  8. HttpResponse response = httpclient.execute(get);
  9. int code = response.getStatusLine().getStatusCode()
  10.  
  11. URL obj = new URL("http://www.google.com/");
  12. HttpURLConnection con = (HttpURLConnection) obj.openConnection();
  13. // you can set the required parameter for your connection object
  14. con.setRequestMethod("GET");
  15. int responseCode = con.getResponseCode();
  16.  
  17. StringBuilder builder = new StringBuilder();
  18. // Set up HTTP post
  19. // HttpClient is more then less deprecated. Need to change to URLConnection
  20. HttpClient client = new DefaultHttpClient( );
  21. HttpGet httpGet = new HttpGet(params[0]);
  22. HttpResponse response = client.execute(httpGet);
  23. StatusLine statusLine = response.getStatusLine();
  24. int statusCode = statusLine.getStatusCode();
  25. if (statusCode == 200) {
  26. //do some work
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement