Android Volley Examples
Posted / Публикувана 2013-05-20 in category / в категория: Android
Volley was announced just few days ago at the I/O 2013. It is a library/framework that helps the developers to create more easily applications that use network requests, and more precisely REST requests. I was very exited to give it a try but unfortunately I found that there are no examples and tutorials. Now, after experimenting with it, I will try to fill to some extend that gap.
Features of Volley:
- Nice and easy API for executing REST requests;
- unifies the mechanism for REST requests by abstracting the "bottom" layer, i.e. you don't care any more about HttpClient or HttpUrlConnection. On lower versions (<= GINGERBREAD) Volley uses AndroidHttpClient and no higher it uses HttpUrlConnection;
- it is very fast. In the I/O presentation the guy states that they tested it at Google with several different apps and Volley was clear winner in all categories;
- it is extensible -- you can use it as a basis to create your own custom type of requests (and response handling/parsing)
You can find the project with the examples at Github:
git clone git://github.com/ogrebgr/android_volley_examples.git
During the import of the project you may need to change the project name to "Volley Examples" otherwise you will end up with a project called "Act_Main".
You will need also the Volley itself:
git clone https://android.googlesource.com/platform/frameworks/volley
After importing Volley you may need to mark it as a "Library project" in order to include it in the example project.
Currently there are 6 examples:
- Simple request -- request against web server and fetches the body of the response. Uses
- Using Volley with GET and POST parameters
- JSON request -- request against web server and parse the response as JSON. Uses
- Gson request -- request against web server and returns Java object that was created using Gson (i.e. converting the result string into JSON and then into Java object.). Uses "custom" made
- Image loading -- request that loads image from server using
- Using cookies
- Using Volley with newer external HttpClient (4.2.3)
- Using Android Volley With Self-Signed SSL Certificate
- Dynamic ListView with NetworkImageView, "endless" paginatio, JSON parsing, etc.
In the next days I will add more examples.
All comments will be welcomed. If you wish to provide samples/examples that you want to be added to this project -- feel free to fork or write me an email (address is here).