I'm upgrading an app to API 23 where org.apache.http is deprecated

来源:互联网 发布:人体工学鼠标 知乎 编辑:程序博客网 时间:2024/06/06 20:29

http://stackoverflow.com/questions/32949626/android-m-org-apache-http-entity-fileentity-deprecated的回答:

If you change your compileSdkVersion to 21, your app will compile cleanly. That being said, there are reasons why Google is backing away from the built-in HttpClient implementation, so you probably should pursue some other library. That “some other library” could be:

the built-in classic Java HttpUrlConnection, though as you have found, its API leaves something to be desiredApache's independent packaging of [HttpClient for Android](https://hc.apache.org/httpcomponents-client-4.3.x/android-port.html)[OkHttp](http://square.github.io/okhttp/) (my recommendation)[AndroidAsync](https://github.com/koush/AndroidAsync)

In particular, OkHttp seems to have a pretty good API for posting a file and posting a multipart form, which should be similar to what your HttpClient code is doing.

0 0
原创粉丝点击