gpt4 book ai didi

android - 在android M中移除HTTPClient有什么影响

转载 作者:行者123 更新时间:2023-11-29 01:03:04 25 4
gpt4 key购买 nike

我最近开始在 Android 中联网,在寻找最好的网络库时,我遇到了这个:linkReadMe 中他们提到了这一点,

最近在 Android Marshmallow (Android M) 中删除了 HttpClient 使得其他网络库过时了”。

现在我很好奇这到底是什么意思?是我们无法使用其他网络库,如 volleyretrofit 等,还是什么究竟是什么意思。

至于我目前的项目,我正在使用这个库implementation 'com.loopj.android:android-async-http:1.4.9' 我刚刚在 android M 上测试了它及其工作,所以我有点困惑。

链接中的说法是否成立?

如果是这样,它究竟意味着什么?

最佳答案

根据文档 here

Android 6.0 release removes support for the Apache HTTP client. If your app is using this client and targets Android 2.3 (API level 9) or higher, use the HttpURLConnection class instead. This API is more efficient because it reduces network use through transparent compression and response caching, and minimizes power consumption. To continue using the Apache HTTP APIs, you must first declare the following compile-time dependency in your build.gradle file:

android {
useLibrary 'org.apache.http.legacy'
}

所以基本上 HTTP 客户端被 HttpURLConnection 类取代了,因为它更快并且消耗更少的电池电量。这意味着你不能使用 volley、retrofit 等。

关于android - 在android M中移除HTTPClient有什么影响,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49644066/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com