Getting Started with Volley: Overview and Import

 
    Volley is a networking libary developed by Google and officially use for Android for query data via network, especially Internet. It's was first introduced during Google I/O 2013. Volley is guaranteed to be easy to use, fast and used exclusively for Android programming invironment. For further details, you can watch this introduction VIDEO from Google Developers.

Why using Volley?

    As note in Android 5.1 (API 22) doc, the org.apache.http classes and the android.net.http.AndroidHttpClient class have been deprecated. These classes are no longer being maintained and you should migrate any app code using these APIs to the java.net.URLConnection classes as soon as possible. But in API levels lower than 14, URLConnection and it's subclasses have a few bugs that were never fixed, so Volley was developed to resolve these difficulties.
    Moreover, with using Volley, you won't need to consider the distribution of the threads (main and net work threads) be cause it handles everything. You can avoid using AsyncTask or Handler to split the network threads separately.
    And most importantly, it's much faster. Some time ago, the Google+ team did a series of performance tests on each of the different methods you can use to make network requests on Android. Volley got a score up to ten times better than the other alternatives when used in RESTful applications.

Import Volley to Android project

    Firstly, we need to download Volley from Google repository. Open Command Prompt (in Windows) or Terminal (in Mac, Linux) to invoke this command:
git clone https://android.googlesource.com/platform/frameworks/volley
    Git will clone this reporsitory to your computer as "volley" folder:
    Now, we will import this libary to our Android Project. After start a new one from Android Studio, click Menu File-->New...-->Import Module... and choose Volley folder:
    Click Finish button and waiting for auto-sync gradle process completed. After this step, Volley has became a module in our project:
    Then, open app/build.gradle file to add Volley dependency, by this final step, this libary will be integrated to our project:
compile project(':volley')
    Syncing our project again by click "Sync Now", now importing process has been done, we can start coding!

Conclusions

    By this post, I have introduce the Volley, an official networking use for Android. In next post, I will present a sample project which using it to request and receive data from Internet, through it, you can deep understanding about this powerful lib that wrote by Google Developer. From now on, you can go to visit Volley official documentation for further details or check this next post to deep learning Volley request types. Thanks for reading and don't forget to subcribes my website to see newest tutorials!

Share


Previous post
« Prev Post
Next post
Next Post »