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.

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top