请问楼主有关于 httpclient 怎么使用的资料没?我在网上找的一些好像是老版本的,跟4.1.2不同有的话发我一份,idlqy#163.com(#替换为@),谢谢啦!!!
解决方案 »
- 如何实现在没有网络的情况下能够读取上次浏览过的新闻
- android中的 单选列表对话框和多选列表对话框 一直出不来
- 考勤系统
- android两个imageview同步执行动画
- 相同长度的字符串,调用SkPaint::measureText()函数返回差距很大的字符宽度值,Why?!
- 求助~Application is not installed on your phone!!
- android 源码修改,让源生的那个组Activity变成拨号的界面!
- Android中service和子线程的用处比较?
- android反编译异常
- FDN 移动手机卡信号
- ubuntu 下编译android 2.3 报错stubs-32.h找不到
- android 做登陆的问题
HttpPost httpost = new HttpPost("http://xxx.xxx.com" + url);
//httpost.setHeader(new BasicHeader("Android-Client", "true"));
try {
MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE );
if (nvps!=null) {
for (int index = 0; index < nvps.size(); index++) {
if (nvps.get(index).getName().equalsIgnoreCase("file")) {
entity.addPart(nvps.get(index).getName(), new FileBody(new File(nvps.get(index).getValue())));
}else {
entity.addPart(nvps.get(index).getName(), new StringBody(nvps.get(index).getValue(),Charset.forName("UTF-8")));
}
}
httpost.setEntity(entity);
}
} catch (Exception e) {
System.out.println("entity error");
}
HttpResponse response = customerHttpClient.execute(httpost); // if(response.getStatusLine().getStatusCode() != HttpStatus.SC_OK)
// throw PostFailedException("..."); HttpEntity resentity = response.getEntity();
StringBuilder serverResponse = new StringBuilder(); BufferedReader br = new BufferedReader(new InputStreamReader(
resentity.getContent(), Charset.forName("UTF-8")));
String s;
while ((s = br.readLine()) != null)
serverResponse.append(s); resentity.consumeContent(); return serverResponse.toString();
}