在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,但是它们都比当前的解决方案复杂得多(不能再使用了)。我正在讨论许多代码行,用于执行与上面相同的功能。例如:本页和本页有人有一个好的固体物较短的解决方案吗?
添加回答
举报
0/150
提交
取消