为了账号安全,请及时绑定邮箱和手机立即绑定

在Android 6(Marshmlow)中不推荐使用org.apache.http.entity

在Android 6(Marshmlow)中不推荐使用org.apache.http.entity

慕村9548890 2019-07-09 15:50:05
在Android 6(Marshmlow)中不推荐使用org.apache.http.entity.FileEntity我正在升级一个应用程序到API 23org.apache.http不受欢迎。我当前(不推荐的)代码如下所示:HttpClient httpClient = new DefaultHttpClient();File file = new File(attr.Value);String url = server_url; HttpPost request = new HttpPost(url);FileEntity fileEntity = new FileEntity(file, "image/png"); request.setEntity(fileEntity);HttpResponse response = httpClient.execute(request);String output = getContent(response.getEntity().getContent());我发现了一些关于如何使用HttpURLConnection,但是它们都比当前的解决方案复杂得多(不能再使用了)。我正在讨论许多代码行,用于执行与上面相同的功能。例如:本页和本页有人有一个好的固体物较短的解决方案吗?
查看完整描述

3 回答

?
一只萌萌小番薯

TA贡献1795条经验 获得超7个赞

HTTPClient最好的替代方法是使用volley。它更容易使用,处理请求队列和缓存您的请求。它完全兼容几乎所有的API级别,直到API 4。

Android文档怎么做。


查看完整回答
反对 回复 2019-07-09
  • 3 回答
  • 0 关注
  • 931 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信