Why should I use OkHttp instead of android httpClient and AsyncTask Why should I use OkHttp instead of android httpClient and AsyncTask android android

Why should I use OkHttp instead of android httpClient and AsyncTask


As always, engineering is about balancing the trade-offs to build the best solution for your requirements.

Using a library instead of the platform is a good example. The API of the platform has existed for quite some time, and for compatibility reasons the Android team has less flexibility in changing those interfaces. A library doesn't have those constraints; for example, if the host supports it OkHttp can use the SPDY protocol for lower latency, compression, multiplexing, etc., which can make your Android app more responsive.

OkHttp and Retrofit - which are projects from Square - can work together. They are also regular Java libraries, so they do not depend on / based on Android. OkHttp handles the lower-level HTTP connection details, while Retrofit simplifies using REST APIs. Retrofit can be used on top of OkHttp, but it is not required.

Check out the projects websites, they are also hosted on github.

http://square.github.io/okhttp/

http://square.github.io/retrofit/