当前位置:编程学习 > wap >>

android 取消http请求和超时代码

现在有个需求是   当http连接很久时我需要设置一个连接超时   还有一个就是用户不想等 直接返回  这时就要关闭这个http请求
不知道那位大侠能帮帮小弟!
http  取消    取消http请求 如何设置http连接超时 android --------------------编程问答-------------------- 我的请求是这样看可不可以:
String strResult=null;
String httpUrl="your url";
HttpGet httpRequest=new HttpGet(httpUrl);
DefaultHttpClient defult=new DefaultHttpClient();
HttpResponse httpResponse=defult.execute(httpRequest);
if(httpResponse.getStatusLine().getStatusCode()==200){
   /*读取返回数据*/
   strResult=EntityUtils.toString(httpResponse.getEntity());
}
补充:移动开发 ,  Android
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,