HttpURLConnection or Apache Http client

Source: Internet
Author: User

There are two ways of network request on Android, one is Java httpurlconnection, one is Apache HTTP clinet, but it is better to choose two ways? Excerpt from Android official blog:
Which client is the best?
Apache HTTP Client has fewer bugs on Eclair and Froyo. It's the best choice for these releases.


For gingerbread and better, httpurlconnection are 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'll be spending going forward.


before Android 2.3, it is best to choose Apache Http Client, on Android 2.3 and later please select HttpURLConnection.
Interested can study the following volley framework:
            if (Build.VERSION.SDK_INT >= 9) {                stack = new Hurlstack ();-->httpurlconnection             } else {                //Prior to Ging Erbread, HttpURLConnection was unreliable.                see:http://android-developers.blogspot.com/2011/09/androids-http-clients.html                stack = new HttpClientStack ( Androidhttpclient.newinstance (useragent)); -->apache Http Client            }


Original: http://android-developers.blogspot.sg/2011/09/androids-http-clients.html

HttpURLConnection or Apache Http client

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.