下载此文档

Android http请求数据 设置超时.doc


文档分类:IT计算机 | 页数:约3页 举报非法文档有奖
1/3
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/3 下载此文档
文档列表 文档介绍
Android http请求数据 设置超时
以前一直在写http请求,设置超时也没怎么认真测试过,今天项目不怎么忙,写了一个http请求测了一下发现以前设置的超时根本没起作用,原来是在发送请求之后设置的超时时间,说着比较迷糊,Android http请求数据 设置超时
以前一直在写http请求,设置超时也没怎么认真测试过,今天项目不怎么忙,写了一个http请求测了一下发现以前设置的超时根本没起作用,原来是在发送请求之后设置的超时时间,说着比较迷糊,还是直接上代码。
http请求代码:
[java] view plaincopy/** * http Post请求的过程 * ***@param postParameters:请求服务端接口需要的数据 * ***@param url:请求接口的地址 * ***@return result */ private static String requestPost(List<NameValuePair> postParameters,String url) { String result = null; BufferedReader in = null; try { HttpClient client = new DefaultHttpClient(); //Represents a collection of HTTP protocol and framework parameters HttpParams params = null; params = (); //set timeout (params, 5000); (params, 35000); // url为访问地址 HttpPost request = new HttpPost(url); UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity( postParameters,"utf-8"); (formEntity); // 通过execute()执行httppost调用 HttpResponse response = (request); // 读取返回结果 in = new BufferedReader(new InputStreamReader(

Android http请求数据 设置超时 来自淘豆网m.daumloan.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数3
  • 收藏数0 收藏
  • 顶次数0
  • 上传人迎春文档
  • 文件大小13 KB
  • 时间2022-01-15
最近更新