Android HttpResponse response Code [duplicate]

2019-02-17 21:48发布

This question already has an answer here:

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

标签: android http
3条回答
Animai°情兽
2楼-- · 2019-02-17 21:54
欢心
3楼-- · 2019-02-17 21:55

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());
查看更多
兄弟一词,经得起流年.
4楼-- · 2019-02-17 22:16

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

Hopefully, it will help you.

Regards,

Android Geek.

查看更多
登录 后发表回答