开发者

Alternative HTTP client library for Android

I'm looking for an alternative HT开发者_JAVA技巧TP client library than what is already included in the SDK. I haven't been able to find any. Does anyone know of any? It doesn't have to be open source.


Many of the issues with Android's built in HttpClient are related issues that have been resolved in HttpClient 4.1. Dirk Boye has created a script to convert the HttpClient 4.1 sources into an Android friendly package. You can find some prepackaged jar files and his script here: https://code.google.com/p/httpclientandroidlib/


You have different options to manage networking in Android:

  1. OkHttp (needs Okio) + Volley + Gson: is a common REST solution for JSON based APIs. You can use each of these tools separately, so for example if you don't need JSON serialization/deserialization you can just use OkHttp + Volley (where OkHttp is the Http client and Volley is a REST library/helper that offers an easy way to load images as well). If you just want an alternative Http client you can use OkHttp(+Okio) which is the best one or among them right now. OkHttp needs Okio(that you can use as well separately) and is a library that complements java.io and java.nio to make it much easier to access, store, and process your data. You can find more information about this solution here..

  2. OkHttp (needs Okio) + Retrofit + Moshi + Picasso. This option is pretty much equivalent to the previous one. Retrofit is comparable to Volley, Moshi to Gson and Picasso is on image loading department. All of this stuff was mainly developed by the same guys and all tied together works like a charm. More on that here.

  3. ION is a very good library that tries to deal with a lot of stuff mention in the options 1 and 2 (Http client, REST helper, uses Gson as well and load images). Better check this out.

  4. Android Async Http: I haven't tried and don't have any information about it, but looks like might be worth taking a look.

I'd say the option 1 is being replace by the option 2. The option 3 has a lot of fans and is developed basically by one (awesome) guy, but offers a LOT of things that you might be not using. That's the reason the Square guys (guys behind option 2) have split everything in 5 different libraries. I can't say much about the option 4. I might be checking it out soon.

Notable mention is Glide, that is (maybe) the best image loading library today developed by the (Google acquired) Bumptech guys.

A guy working on Okio/OkHttp was working in Google on the SDK http client, worked on Gson and is working on Moshi. That's the reason I am more inclined for the option 2 nowadays, people use to do better stuff than previously, or at least not worse.


OkHttp by Square is a good alternative.
Volley made by Google is also great in design.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜