Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AndroidHttpClient versus HttpUrlConnection for API Level 9 and above

Which is better for API Level 9(Gingerbread) and why? Is there any benefit to use AndroidHttpClient over HttpUrlConnection?

Any help or guidance will be well appreciated.

like image 298
abhishek kumar gupta Avatar asked Feb 28 '14 12:02

abhishek kumar gupta


1 Answers

Google doesn't recommend using AndroidHttpClient, only on very old Android versions.

But as you can see in many questions on SO, HttpURLConnection is not easy to use. It's very low-level and doesn't have a comfortable interface. You have to know quite a lot how it's working internally and if you have luck, you get exceptions when you use it the wrong way.

For that reason many libraries have been developed for Android developers. You can find a list (and a concrete implementation BTW) at DavidWebb. There are low-level libraries and some very powerful which take the burden of background processing from you.

Edit

Q: Is there any benefit to use AndroidHttpClient?

A: From programming point of view, AndroidHttpClient is much easier to use. But as Google says, due to difficulties with backward compatibility, they cannot improve this class and instead put all efforts in improving HUC (abbr. for HttpURLConnection). For me this reads like "we will let AndroidHttpClient die". Of course this class will be present in all future versions of Android SDK I suppose, but HUC does many intelligent things under the hood, e.g. transparent download compression.

tl;dr I wouldn't use AndroidHttpClient for current app development.

like image 148
hgoebl Avatar answered Nov 16 '22 04:11

hgoebl