Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 14

Volley

Easy, Fast Networking for Android

TOPICS

What is Volley?

Everything you need

About Volley

What Volley Provides

Volleys Architecture & How It Works

Implementation

Why Volley?

Exception !

Biblography

Volley ! Is it the same ?

volley (\v-l\), n.:

a burst or emission of many things or a large


amount at once

volley (\v-l\), n.:


the flight of the ball (as in volleyball or
tennis) or its course before striking the
ground

Everything you need

JSON, images, raw text

Memory and disk caching

Powerful customization

abilities Debugging and tracing tools

About Volley

Volley is a network library


developed by the google &
introduced during the google I/O
2013

It is developed to overcome the


challenges occurring in the
native methods to process the
data over a network

Its main function is to work on


network thread to fetch data on
the main thread of the
application

What Volley Provides

On Front - End
Great for RPC-style network operations that populate UI
Fine for background RPCs

On Back End
Parallel hits in one go
Response can be format as Dev. Wants
Exceptions Handler is provided

Volleys Architecture
It works on three levels :1st It works on the Main thread of the application
where its start to hit for the request made by the
Dev. & Dev. only handles the response
2nd It works on Cache thread , in this thread volley
checks whether the request is repeated or not if it is
repeated it takes the response from the cache where
everything is saved if not it will pass the request to
network thread.
3rd it works on Network thread, where it makes the
request and get response from the server & forward
the response to the app.

Implementation

It contains only to classes to operate over the network and to get the response

1st is Request class :- where all the request are made w.r.t to the
context of that class like
Volley.newRequestQueue(context);
where newRequestQueue is the method to add as many
request as you want top process parallel

2nd is the Response class :- where the response of the request is taken.
There are three types of responses you can get :1.

String Request where the request made is for getting the string

2.

Json Request where the request is made to get the json object or array

3.

Response<T> , this is the custom request where the developer can request in the form he/she wants to receive

Like :-

new JsonObjectRequest(Method.GET, url, null,


new Listener()
{ public void onResponse(JSONObject jsonRoot)
{ mNextPageToken = jsonGet(jsonRoot, "next", null);
List items = parseJson(jsonRoot);
appendItemsToList(item);
notifyDataSetChanged(); } } );

Why Volley Library ?

To Avoid HttpUrlConnection & HttpClient methods


since for the lower API Levels these library doesnt
work perfect or contain bugs in
processing the data.
And also HttpClient method is deprecated on or abhove
API Level 21 .

To Avoid Asyntask
basically a handler which is used to work
background thread or services.
The main problem with the Asyntask was
works in serialization method like FIFO. So,
processing time increases.

on
that it

Secondly, there is problem in working with the


BLOB objects in order to process data.

It is Faster
As per the test done by the
google+ Volley library works faster
around 10x times when using
RESTful APIs
i.e.,
Representational State Transfer

It Caches Everything
It Localy make objects for the
request already got hit

It is best to perform small MetaData


Operations

Exception

There is only one exception for Volley library


i.e., it cannot be used to operate for streaming
operations as well as large downloads

Biblography

Google I\O 2013 Seminar

Google Images

Various Blogs

Thank You

BY Harshdeep Singh

You might also like