Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache HTTPClient 4.x vs HttpUrlConnection - which one is faster on Android?

I need to optimize the speed of data loading in my app.

I remembered that according to the post on the Google Developers blog HttpUrlConnection is advised to be faster and more lightweight.

For Gingerbread and better, HttpURLConnection is the best choice. Its simple API and small size makes it great fit for Android. Transparent compression and response caching reduce network use, improve speed and save battery. New applications should use HttpURLConnection; it is where we will be spending our energy going forward.

But the thing is that a lot of people here recommend ApacheHTTPClient but Google says that HttpUrlConnection is better.

Which http client would you recommend to improve overall speed? Let's assume for that question that complexity of code which I have to write doesn't matter.

like image 327
Roman Minenok Avatar asked Nov 04 '22 04:11

Roman Minenok


1 Answers

I think it's pretty clear from the android-developers blogpost. When it comes to Android you can't really get a better authority than Google themselves. So, yes, it's true ;)

"For Gingerbread and better, HttpURLConnection is the best choice. Its simple API and small size makes it great fit for Android. Transparent compression and response caching reduce network use, improve speed and save battery."

What part of that has you uncertain.

like image 54
brk3 Avatar answered Nov 11 '22 13:11

brk3