Wireless development is bound to interact with the server, which naturally requires the use of a toolkit similar to httpclient to send and accept HTTP requests. Some of these are commonly used:
1. Apache HttpClient (used prior to Android2.3)
2. Android Simplified Extended version httpurlconnection
3. Google launch Volley (use httpclient before Android2.3, then use httpurlconnection)
4. Git open source project Okhttp (using Http+spdy protocol)
5. Android-async-http
6. Retrofit (using okhttp as the Transport layer by default)
7. Android Query
8. Android Asynctask
Comparison of HttpClient and HttpURLConnection:
For httpclient Everyone is more familiar with, here does not do superfluous elaboration, why use HttpURLConnection? The main reason is that httpclient, although stable, but too large, on Android is not easy to upgrade and expand, so there is a lightweight httpurlconnection. HttpURLConnection can refer to the following blog for extension points compared to httpclient.
Reference:
http://blog.csdn.net/guolin_blog/article/details/12452307
Http://android-developers.blogspot.com/2011/09/androids-http-clients.html
Volley used in the httpurlconnection, then volley on the httpurlconnection there is no improvement? The relevant information has yet to be consulted.
Android comes with the Asynctask: not recommended.
Disadvantages:
1. Does not support environmental changes;
2. Cannot cancel the network request;
3. There is no easy way to make concurrent API calls;
4. Only one Asynctask task can be run at a time;
5. The Ancle () method does not work;
6. When activity is destroyed and the activity is referenced, memory leaks may occur;
7. Activity recreated may result in loss of asynctask results;
8. Serial or parallel uncertainties, depending on the level of the API and different;
Asynctas the Dark Side: http://bon-app-etit.blogspot.in/2013/04/the-dark-side-of-asynctask.html
OkHttp, volley, retrofit contrast:
Features of Volley:
1. The advantage of volley is the processing of HTTP requests for small files;
2. Okhttp can also be used as the transport layer in volley; Reference: Https://plus.google.com/+JakeWharton/posts/eJJxhkTQ4yU
3. Volley has good support in processing high-resolution image compression;
4. Networkimageview is more conservative in GC usage patterns and more aggressive in request cleanup, Networkimageview relies only on powerful memory references and when a new request is from ImageView or imageview leaving the screen All request data will be cleaned out.
5. Volley is better than retrofit in memory error handling.
Features of Retrofit:
1. Easy to use REST API;
2. The transport layer is using okhttp by default;
3. Support for NIO;
4. Excellent API documentation and community support
5. Faster than volley in speed;
Features of Okhttp:
Support Spdy (Request header compression, parallel request, forced SSL, server push);
Performance baselines for the three:
The comparison between volley and retrofit, reference: http://instructure.github.io/blog/2013/12/09/volley-vs-retrofit/
Comparison of the three references: Http://stackoverflow.com/questions/16902716/comparison-of-android-networking-libraries-okhttp-retrofit-volley
Some network communication packets that are commonly used in Android development (RPM)