Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android HttpResponse response Code [duplicate]

Tags:

android

http

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

like image 450
Leo Avatar asked Nov 16 '11 08:11

Leo


3 Answers

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

like image 200
Sean Owen Avatar answered Sep 21 '22 18:09

Sean Owen


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

Hopefully, it will help you.

Regards,

Android Geek.

like image 39
Cool Java guy מוחמד Avatar answered Sep 19 '22 18:09

Cool Java guy מוחמד


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());
like image 37
Android-Droid Avatar answered Sep 21 '22 18:09

Android-Droid