Volley download
- git clone Https://android.googlesource.com/platform/frameworks/volley
after the introduction of the project can be downloaded, volley suitable for small data but continuous communication, as for the download file support is not very good, it is recommended to use Android Downloadmanager,.Android networking requires network permissions, and the memory card read and Write permissions are not missing ... volley the most in the volley.class,stringrequest,jsonrequest,imagerequest. Of course you can do it yourself. Inherit request<t>. Custom Volley.class are also required for general development in the project. For example, custom On-disk cache directory, useragent, can modify volley original project's files, or custom Myvolley. two ways to choose by yourself. get the source code of Baidu homepage
Stringrequest request = new Stringrequest (host, New listener<string> () {@Overridepublic void Onresponse ( String response) {Logg.logg ("Request runs successfully");//Output results ..... Logg.logg (Response)}, new Response.errorlistener () {@Overridepublic void Onerrorresponse (volleyerror error) { Logg.logg ("Request error Run");}); Queue.add (request); Queue.start ();
Get JSON
Jsonobjectrequest objectrequest = new Jsonobjectrequest (JSON, NULL, new response.listener<jsonobject> () {@ overridepublic void Onresponse (jsonobject response) {Logg.logg (response.tostring ());}}, NULL); Queue.add ( Objectrequest); Queue.start ();
Load pictures from the network do not use ImageView, but to use Networkimageview. and to achieve imagecache. Suggestions.
The POST request needs to be rewritten in the Stringrequest GetParam method, Demo: http://download.csdn.net/detail/u014781439/8324529
Android HTTP Framework Volley learning: