Networking is something that you cannot avoid in android projects.Whether downloading or uploading images,requesting data from server or sending data to server from an API, you are doing is “Networking”.
A common problem that android developer face when they start working with networking is which library should be used? What’s the difference ?
Below are the libraries in android which helps developer to cover most of the needs.
Its an third party library introduced by Square. OKHttp supports below features:
• It supports Http/2 protocol.
• Connection pooling can used.
• Cache eliminates multiple networking calls.
• It supports both synchronous and asynchronous calls.
Volley is an HTTP library developed by Google used to transmit data over network.It is been introduced to make networking calls easier and faster.
• Prioritization and queuing of request.
• Cache and memory management requests.
• Cancelling of requests.
• Easier management of UI.
• Offers easier customization.
Retrofit is a REST client for android and java developed by square.It makes it very easy to retrieve and upload JSON via the restful api. Retrofit automnatically serialises the JSON response using POJO.
Converter modules provided by square are as follows:
• Simple XML
• Difference between volley and retrofit :
• Retrofit does not supports caching.
• Retry policy can be set in volley using setRetryPolicy method .It also supports customized request timeout,no of retries.Retrofit does not supports retry mechanism.
• Type of request :
• Volley has an inbuilt support for image loading with custom view called NetworkImageView . Retrofit does not provide any such features.