HTTP request library for android

900 Views Asked by At

I'm looking for a good HTTP library for my android app. I've been using AsyncHTTP by loopj (and I've only ever used that), but it's making my app crash when the network connection is lost. Also, it doesn't meet my requirements well. So far, I've found okhttp by Square and volley by Google. But I'm not sure which suits my purposes better. The following would be my requirements,

  • Small frequent http request for JSON results
  • JSON parsing
  • Async operation with callback methods
  • Caching, with functionality for force re-fetch

Some insights into how these differ and what I should be using, would be immensely helpful.

3

There are 3 best solutions below

2
On

Combination of Robospice and Google Http Client/Spring/Retrofit (your choise) is what you are looking for. RoboSpice perform async requests by using one of this networking library with respect to Activity/Fragment lifecycle and also handle caching. JSON are parsed by this libraries.

2
On

OkHttp is an HttpClient. If you want JSON parsing and callback methods you should use Retrofit which uses OkHttp internally. Both Retrofit and Volley are suitable for your requirements. Volley also has an image downloader in it but if you want image downloading when using OkHttp you need to use Picasso from square (which I suggest).

I personally suggest using Retrofit+Picasso. They are lightweight and perform really well and they have a decent documentation.

0
On

I personally used Volley for caching purpose, and Picasso for image downloading.

RoboSpice is another library which will be useful for caching.

Check out bellow links to make final decision :

Comparison of Android Networking Libraries

Retrofit

RoboSpice vs Volley