Android Volley Tutorial (Android PHP MySQL) - How to Setup Volley Library (Part 1)

Android Volley Tutorial (Android PHP MySQL) - How to Setup Volley Library (Part 1) - Hello friends Android tutorial and tips trik, The article you are reading this time with the title Android Volley Tutorial (Android PHP MySQL) - How to Setup Volley Library (Part 1), we have prepared this article for you to read and download the information therein. hopefully fill posts article -, article (Part, article 1], article android, article How, article Library, article MySQL), article PHP, article Setup, article TO, article Tutorial, article Volley, we can write this you understand. Well, happy reading.

Title : Android Volley Tutorial (Android PHP MySQL) - How to Setup Volley Library (Part 1)
link : Android Volley Tutorial (Android PHP MySQL) - How to Setup Volley Library (Part 1)

Baca juga


Android Volley Tutorial (Android PHP MySQL) - How to Setup Volley Library (Part 1)

Hello everyone, my name is Oum SaokosalToday 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, Twitterand GitHub.

I will make four videos about android volley.

The first part is about volley library singletonand RequestQueue.

The second one is about how to send and readdata from PHP and MySQL.

Part 3 I will talk about how to convert datainto JSON and send it to the custom List view.

PART 4 I will talk about how to send imagesto server.

So Android volley is about to do multitasking.

In early version of Android, you could justdo multitasking on a mainframe but you got a lot of problems like a memory leak.

Sometimes you have to wait a task to be completedon a main thread for very long time.

Then Android 3.

0 to use another library called AsyncTask.

So.

That was good.

That was enough for many applications.

But still AsyncTask is just asynchronous.

Until task A completes, Task B has to wait.

Something like this.

Until you hit the floor, You have to wait in the air something likein in the picture here.

It's also a first in first out.

Something like in the queue.

The waiter hasto complete a person task.

Then and then the next can come.

So what if you have a long queue like this.

Then Android introduce volley library.

People confuse volley library is somethinglike a bouncing ball like a volleyball.

It's not it's not a volleyball.

Volley mean something different in Englishis something like you shoot arrows in the air at the same time and you are not shooting one arrow.

You have many people shooting arrows at thesame time.

This is what volley look like.

Okay OK let's go to Google.

If you type android volley library you willsee the first one from Android.

There is a good lesson about this and youcan read it but first I want to show you about how to set it up.

So.

Android is a part of android open source projectso 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.

So you have to use this instead.

If you want to use his, and you can use thisone.

If you are not happy with this you can justdo it yourself.

You can just go something like this.

Create android volley library you will goto this link in this blog.

we talk about how to do volley library convert it to jar file.

First one you need 'git' and the 'ant' to writesome code yourself and then just get a jar or you can just download the jar file fromhere.

So you can just download here or maybe youcan just use this one.

So let's try this one first.

So you go to your project you next and thisis the basic activity.

Okay before anything else.

I just want to point out something.

I'm using Android studio 2.

0 and I updatedto Android SDK 23.

3 So your interface might be different frommine little bit more like like in Java folder you have three sub folders instead of two butit doesn't matter.

Just for testing.

So what you have to do is the same thing justin the main activity.

So you have to go to build that grid on thesecond one and you add the library that you got from the Internet this one and click onsync now and you need the Internet for this.

So to test it.

You can test by writing some code and yougo to get started.

This one is part of the volley library RequestQueue.

Alright.

Let's check it out.

Yeah.

Now you have been imported correctly.

You don't see this import maybe you don'tsend authority or correctly on Windows.

You go to file and set thing nothing or what'sset thing that thing or here.

Mac, you go to or here and type "auto import" in here.

You have to check all three checks here.

Now you've have the library installed andreading but you'll need one more thing that the RequestQueue here is a class and you cancreate many objects from that which is not good.

So Android introduced another concept.

Yougo to setting up a request queue And you go down and it is called Singleton.

Singleton is a part of Design Patterns from a gangof four which help you to prevent and create many objects from one class.

So this part and make sure that you have onlyone object from a class.

So this just for the request queue but thissingleton.

Just copy the code and go back to Android.

And go here new Java class and you cancall it what you want that's call my singleton.

The reason that you want to put the same name as MySingleton.

When you get any problem for example you'restuck with something, you can just go and type something like oh android volley mysingletonthing.

So there is a suggestion from Google and maybesaid error and you will see a lot of StackOverflows the same thing use the same class name and methodthat you can get code and fix the error here.

So stick with the name MySingleton.

Okay.

Now you've got one more problem here LruCacheand you go to the very end of LruCache in control+space.

Now you need to use Android support android.

Support.

V4.

Utiland the error is fixed.

One more thing you have to go to Android manifestbecause you need the internet.

So you have to do is use the "uses permission" Internet you ask for the Internet uses permission to search so now you are good to go.

And youcan see some for example over here.

So the main thing here is the RequestQueuebut RequestQueue now become MySingleton and MySingleton now can add as many as RequestQueue you like.

So what you have here is where the clone andmay be you just has it here.

You can write a button and click on that andyou get the data.

But now just like like this if you don't needthe menu just delete this.

And here you can call any requests to stringyour request and it is part of the library.

You can call string requests, network request,task request, JSON request.

The basic one is for string request.

So let's start with the string request hereThere are three things.

The first one is a method is the GET or POST.

If you don't mentioned the GET or POST, then the default is GET.

And then you need a URL.

What is your URL and now maybe just type "Google" And make sure that you have the 's' here because Google uses https So you need another one is the error.

Also the respond but error respond and thisone is te data respond.

So if you are using the String request here.

So when you get the data you want to sendthe log and log.

D.

Now I want to create a TAG and simple name.

maybe display a responseand there will be a lot code from Google here.

If something error maybe.

OK.

Here you are using 'this' in Anonymous class So you have to do is get application contexthere.

Now you are good to go and I'm using Genymotion.

And you are free to use anything you want.

Okay let's see the Log here.

So you used the name of this class.

Now you can see this one.

this is the data that you retrieve form Google.

Com.

If you are not sure you can just go to Googleor you go on like there.

And right click > view source.

Now should be something similar here few morething.

Okay very similar It's not exactly the samebecause Google use some flexible code.

Here I use 'kh' here I use '.

Com'If I change to '.

Kh', it must be the same thing Okay let's say you don't put the permissionhere.

Just delete it.

And for the Android 2.

0 there are 2 buttons here, Usually you just click run and run automaticallyfrom the start but now you have to stop.

You go run from here something like a minorchange you can just run it like this.

It will instantly run and then it faster butwe want to change something more.

Something like permission like to stop it.

There is an error now.

Because if you don't put the permission overhere and let's check the Log here.

It's not easy to see but if you see somethinglike this you know that you forget to add a permission in Android manifest.

So run it back.

OK.

Now you're good to go.

And if the URL is error, then you gonnaget another message.

OK.

And now let's try to get data from local host.

I use XAMPP so if you use WAMP it's okay.

It's up to you.

Start it now.

Before I move on toread the data from android.

I want to show you something which is veryimportant because when you are using local host.

You are using a different thing.

Unlike onPC you have only one local host but here in android emulator, you have another local host soif you say now I want to say being local host like this you can not call to the PC localhost.

Instead you have to use 10.

0.

3.

2.

This number 3 is for GenyMotion and if youare using the native Android emulate you have you use the 10.

0.

2.

2 OK.

If you are using another port, type port likethat.

If you are using 80, the default port, you don't have to specify like this.

and then maybe project.

Your project like this or maybe next file.

OK.

So usually you cannot get the data easilybecause the problem is not about this code or this library but it's about the wamp permission.

So if you go to Android if you go to Googleand you type something like this WAMP permission denied then you will see a lot of a problemhere and the problem comes from them WAMP try not to let you call from another IP addressbecause the default IP address is 127.

0.

0.

1.

But now you are using another IP address callthe local host so you have to go to your phpmyadmins and fix like this and then could change fromhere to here and maybe you just say something better.

And then maybe you have to remove somethingfor XAMPP.

I think you have to go to here config andopen config like this.

Okay around something over here.

So you have to figure out yourself and plusyou have to make sure that you can browse local host from the android emulator.

So yougo to home.

And you go to local browser here and you finda thing.

Now you don't type look for a host but youtype 10.

0.

3.

2 the three is for the Genymotion then go on good thing to build in one is usingnumber two.

If you see something like this then you areright.

OkayYou cannot see something like this you would see something like permission denied or accessforbidden then you have to Google and find a solution.

Okay.

So now I have project.

so customer and it is in the product here.

Right it is on already the first thing.

So let's go back.

I will going to explain this on later.

Now this is do you want to replace that fromhere.

And change the local host to 10.

0.

3.

2 OkayNow you see the data right here.

So lastly I want to talk about the request.

Like I said before a singleton can take asmany requests as it wants.

So you can help this for the Google and maybeanother one so another one here is Google.

Kh for Cambodia.

And I call it 1 and this one 2.

Now you have two requests.

So let's see.

Okay let's see what's going on here.

Now you see the data the first one.

thisfrom local host and the second one is from Google.

But if you notice this actually Google isfirst okay because I called the string request one first and then the second one.

The first is Google.

The second one is local host.

But when you see the data here you get thedata from local host first.

Why.

Because it is the multitasking.

It doesn't care which task go first.

It's not first in first out but it's the multi task.

it's a real one.

And if the data the first one is completedfirst then send back to your Android first even though the second one does come later.

But then it doesn't care.

It cares about theamount of data and the time of requesting that it will send it back as soon as it iscompleted.

Okay.

That is a cool thing about volley.

OK that's it for part one.

I will meet you in part 2.

And please don't forget to subscribe to my channelto wathc the part two and three and other other videos as well.

as well.

Thank you for watching.

And I will see you in the next video.

Thank you.



Thus Article Android Volley Tutorial (Android PHP MySQL) - How to Setup Volley Library (Part 1)

That article Android Volley Tutorial (Android PHP MySQL) - How to Setup Volley Library (Part 1) This time, hopefully we can give you all of the benefits. Well, I'll see you in another article post.

You now read the article Android Volley Tutorial (Android PHP MySQL) - How to Setup Volley Library (Part 1) the link address http://svedda79.blogspot.com/2016/04/android-volley-tutorial-android-php.html

0 Response to "Android Volley Tutorial (Android PHP MySQL) - How to Setup Volley Library (Part 1)"

Post a Comment