Volley


 

  1. Simple Request
  2. StringRequest
  3. JsonRequest
  4. ImageRequest
  5. ImageLoader
  6. NetworkImageView
  7. Priority
  8. Post Request
  9. Cache Handling
  10. LRUCache

 

Steps to do before:

  1. Clone the repo from here.
  2. You can use the volley as a library project to your main project or you can simply generate volley.jar and paste it in project libs folder. To generate volley.jar, move into volley dir and execute below commands.
    android update project -p.
    ant jar
    You can find generated volley.jar in volley bin folder.
  3. For Eclipse: Copy the downloaded library file to “libs” directory of the project. Right click on jar file -> Build Path -> Add to Build path.
    For Android Studio: Copy the downloaded library file to “libs” directory of the project structure and add compile files(‘libs/your lib name here’) is in your build.gradle.

 

1. Simple Request

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open AndroidManifest.xml and add following code :

ScreenShot:

volley_simple volley_simple2

Download SourceCode

 

 

2. StringRequest

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open src -> package -> Create new class MySingleton.java and add following code :

Step 5 : Open AndroidManifest.xml and add following code :

ScreenShot:

volley_stringrequest volley_stringrequest2

Download SourceCode

 

 

3. JsonRequest

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open src -> package -> Create new class MySingleton.java and add following code :

Step 5 : Open AndroidManifest.xml and add following code :

ScreenShot:

volley_jsonrequest

Download SourceCode

 

4. ImageRequest

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open src -> package -> Create new class MySingleton.java and add following code :

Step 5 : Open AndroidManifest.xml and add following code :

ScreenShot:

volley_imagerequest volley_imagerequest2

Download SourceCode

 

5. ImageLoader

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open src -> package -> Create new class MySingleton.java and add following code :

Step 5 : Open AndroidManifest.xml and add following code :

ScreenShot:

volley_imageloader volley_imageloader2 volley_imageloader3

Download SourceCode

 

6. NetworkImageView

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open src -> package -> Create new class MySingleton.java and add following code :

Step 5 : Open AndroidManifest.xml and add following code :

ScreenShot:

volley_networkimage volley_networkimage2 volley_networkimage3

Download SourceCode

 

7. Priority

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open src -> package -> Create new class MySingleton.java and add following code :

Step 5 : Open AndroidManifest.xml and add following code :

ScreenShot:

volley_priority volley_priority2

Download SourceCode

 

8. Post Request

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open src -> package -> Create new class MySingleton.java and add following code :

Step 5 : Open AndroidManifest.xml and add following code :

ScreenShot:

volley_post volley_post2

Download SourceCode

 

9. Cache Handling

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open src -> package -> Create new class MySingleton.java and add following code :

Step 5 : Open res -> menu -> main.xml and add following code :