I need to download a web page on an Android app and I am having a hard time deciding whether to use the Android Apache HTTP client or Java’s URLConnection.
Any thoughts?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For most things I’d say that
HttpClientis the way to go. However there are some situations and edge cases where I’d fall back to aURLConnection. Examples of edge cases here and hereEDIT
A similar question has been asked before: httpclient vs httpurlconnection.
I would assume thatI would findHttpUrlConnectionis somewhat faster as theHttpClientis built on top of the standard Java libraries. HoweverHttpClientcode much quicker and easier to write and maintain. According to a comments below, the core elements ofHttpClienthave been performance optimised.If performance is a major concern your best bet is to write two clients, one using each method, then benchmark them both. If you do this, please let us know the results.