// 根据Post请求获得响应对象response
public static HttpResponse getHttpResponse(HttpPost request)
throws ClientProtocolException, IOException {
HttpClient client = new DefaultHttpClient();
//请求超时
client.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 6000);
//读取超时
client.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, 6000);
HttpResponse response = client.execute(request);
return response;
}
记录一下,以后注意!
Android get/post方式请求网络设置超时
最新推荐文章于 2021-05-25 17:42:15 发布