5

I am trying to get the response code for the HttpReponse. There is no method for get the response code directly.

Leo
  • 63
  • 1
  • 1
  • 6

3 Answers3

20

HttpResponse.getStatusLine().getStatusCode() is what you are looking for.

Sean Owen
  • 66,182
  • 23
  • 141
  • 173
2

Please find the link Android: How get the status-code of an HttpClient request

Hopefully, it will help you.

Regards,

Android Geek.

Community
  • 1
  • 1
Cool Java guy מוחמד
  • 1,687
  • 4
  • 24
  • 40
2

This is how you get Response code if you are using HttpUrlConnection :

int status = ((HttpURLConnection) connection).getResponseCode();
Log.i("", "Status : " + status);

And here is if you are using HttpClient :

HttpResponse response = httpclient.execute(httppost);
Log.w("Response ","Status line : "+ response.getStatusLine().toString());
Android-Droid
  • 14,365
  • 41
  • 114
  • 185