android - 在 android 上用一些 "setEntity"方法可以很好地替代 HttpPost 和 HttpPut 吗?

标签 android http http-post http-put

我目前正在使用 HttpPost 和 HttpPut 将实体从我的移动应用程序发送到服务器。我正在使用 setEntity 将实体从数据库发送到服务器,它简单、直接并且运行良好,但它现在已从版本 23 的支持库中删除。 我发现的一些替代 HttpPost 和 HttpPut 的东西没有任何像 setEntity 这样的方法,重构会非常复杂。没有这样的方法还是我找不到?有什么建议么? 我尝试使用

添加回 Http
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpclient:4.5'

但是没有用。

最佳答案

httpclient-android是适用于 android 23+ 的 apache HttpClient 端口。您可以将它包含在 --

compile "cz.msebera.android:httpclient:4.4.1.1"

您还需要更改导入语句以使用新的包名称。

关于android - 在 android 上用一些 "setEntity"方法可以很好地替代 HttpPost 和 HttpPut 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34335553/

相关文章:

android - 加载 APK 到 TestDroid

Android 和 Google Play : several applications with the same name?

android - 无法使用Jitpack编译 fork 的Github Repo

python - 带有获取请求的 Http 客户端

javascript - 在 azure 函数 (js) 中,异步/等待调用后的 POST 请求不起作用

java - Eclipse 和 Android Activity 中的错误似乎无法弄清楚

c# - HttpListener 类可以用于嗅探吗?

http - 如何通过 telnet POST REQUEST 保存文件?

rest - Powershell中未显示API响应

java - 使用谷歌应用引擎上传图片的一步上传