Android Volley Tutorial (Android PHP MySQL) – How to Setup Volley Library (Part 1)
In this series of Android Volley Tutorial, you will learn how to set up Android Volley library in Android Studio. Because there is not built-in Android Volley library for you, you have to go into Android tutorial site and copy and paste some of there gradle and code.
In Android, connecting android with PHP & MySQL is not always easy. In the early version of Android (before Android 3.0 API 11), you could connect to network in the main thread. However, it caused tremendous problems including memory leaks and ANR.
Since Android 3.0 API 11, Android released a library called AsyncTask which let you run the networking connection in a separate thread. I made a generic library for that which you can find at at https://github.com/kosalgeek/generic_asynctask_v2 and many video tutorials about it such as https://www.youtube.com/watch?v=e4eFBQmWs8Q
However, the library was not enough because it followed the First In First Out (FIFO) rule. What if you had a long queues of tasks to be completed at the same time? Therefore Android just released Volley in Google I/O 2013. It is a promised to overcome the FIFO and became a real library for multitasking. It is faster and cached everything.
In this video, you will learn the basic of volley library and how to install it. Also you will learn to create a singleton class for RequestQueue and make string requests to retrieve data from the web.
Below is the transcript:
Hello everyone, my name is Oum Saokosal
Today we talk about how to make android with PHP and my app using Volley. This is where you can find me. You can find me on YouTube, Facebook, Twitter and GitHub. I will make four videos about android volley. The first part is about volley library singleton and RequestQueue. The second one is about how to send and read data from PHP and my SQL. Part 3 I will talk about how to convert data into JSON and send it to the custom List view. PART 4 I will talk about how to send images to server.
So Android Volley is about to do multitasking. In early version of Android, you could just do multitasking on a main thread but you got a lot of problems like a memory leak. Sometimes you have to wait a task to be completed on a main thread for very long time. Then Android 3.0 to use another library or acting power.
So. That was good. That was enough for many applications. But still axing task is just asynchronous until task A complete. Task B has to wait something like this until you hit the floor. You have to wait in the air something like in in the picture here.
It’s also a first in first out. Something like in the queue.The waiter has to complete a person task. Then and then the next can come. So what if you have a long queue like this.
Then android in the use volley library. People confuse volley library is something like a bouncing ball like a volleyball. It’s not it’s not a volleyball. Volley mean something different in English is something like you shoot arrows in the air at the same time and you end up shooting one arrow. You have many people shooting arrows at the same time. This is what volley look like.
Okay OK let’s go to Google. We will type android volley library you will see the first one from Android. There is a good lesson about this and you can read it but first I want to show you about how to set it up.
So. Android is a part of android open source project so you can clone the project and use it for free. Or if you don’t want to do it yourself. Maybe you just use this one. The second link you go here. But he said that his library is deprecated.