I’m building an Android app that will communicate with a REST service using HTTP and HTTPS for downloading JSON and file data. I’m looking for a HTTP networking library to use and am evaluating options. I’ve found one called AsyncHttpClient (loopj.com/android-async-http) which looks good and I see Instagram uses it, but I see it’s built on the Apache HttpClient libraries and I seem to recall reading somewhere that the Apache library is being left behind in favour of HttpURLConnection. Is this something I should be concerned about? Is there another library I should consider instead? I planned to target a minimum Android SDK of 2.1 if this makes a difference.
I’m building an Android app that will communicate with a REST service using HTTP
Share
You are right about
HttpUrlConnectionrecommendations, however, you can check it’s initial source and check the rootcause of this recommendation, does it really applies to you?http://android-developers.blogspot.com/2011/09/androids-http-clients.html
The major constrain of the
HttpUrlConnectionfor me – is that it doesn’t support Multipart initially. Of course it’s not so hard to add, but it looks weird.Also, Apache implementation is quite good basically, just one advice – don’t forget to use
AndroidHttpClientinstead ofDefaultone.And about JSON – I will recommend separate library for that, most probably – Google’s GSON http://code.google.com/p/google-gson/ .
For me
AndroidHttpClient+ Gson worked pretty fine.Good luck