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