如何设置android HttpPost 连接服务器超时
程序员文章站
2022-07-13 17:27:32
...
之前试了几种方法都没能成功,此处忽略,最后还是*拯救了我啊,上代码
// 根据内容来源地址创建一个Http请求 HttpPost request = new HttpPost(SERVER_URL); //设置请求超时 int timeoutConnection = 3 * 1000; HttpConnectionParams.setConnectionTimeout(httpParameters,timeoutConnection); //设置响应超时 int timeoutSocket = 5 * 1000; HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket); // 发送请求并获取反馈 DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters); HttpResponse httpResponse = httpClient.execute(request);
上一篇: Myeclipse下切换SVN用户