发送http请求 得到网络请求返回状态消息:
方法如下:
public int getRespStatus(String url) {
int status = -1;
try {
HttpHead head = new HttpHead(url);
HttpClient client = new DefaultHttpClient();
HttpResponse resp = client.execute(head);
status = resp.getStatusLine().getStatusCode();
} catch (IOException e) {
}
if (DEBUG) {
Log.v(TAG, "status=" + status);
}
return status;
}
status 返回值是404, 500, 502, 504等http状态消息