So here this class main activity must conform or implement the unkind action callback.
Actually the interface so here main activity extends app comp. activity.
Now after this app compactus they can here implements Google API client.
OK so this is really important.
If you can't access this will it be a client.
That means that inside the bill create a file the applet will get built with that file.
You did not actually put this line of code here inside these dependencies plug.
OK.
So let's go to the main of the class.
So Google API client dot Google API client dots connection callbacks.
OK collection callbacks so we must conform to this interface.
Just press on until your keyboard and they put a comma here.
So you need to I need to also conform to another interface and that interface is Google API client that's
actually on connection failed listener.
OK.
We must actually conform to these interfaces.
We must actually implement these interfaces.
Google API client connection codecs and Google API client that and connection failed listeners.
So now that we actually conformed to these interfaces now that we implemented these interfaces we must
actually implement them Misfit's that are inside of these interfaces.
So if we actually hold down to the common key on my keyboard so if you are using a Windows machine you
can actually hold down the control key on your keyboard and just click on this connection callbacks
here.
As you can see it guided me to this Google API client class.
You can see that we have this interface here.
Inside is a class you can see that it says public interface connection callbacks.
Right.
So we have these two integer values and cause service disconnected int cause network lost and we have
the Smurfit unconnected on connection suspended right.
This means that we must implement these two methods inside our main activity class because we actually
implemented this interface this unconscious callbacks interface.
Right.
So this unconvicted if it is going to be called whenever that we actually can connect to that location
services in order to get the user's location or any others any other location.
Right.
And we have these connections suspended.
So this is going to be called whenever something happens when ever a problem is actually occurred and
we cannot currently access the location.
So it is going to be suspended.
So let's go back to the main activity class here.
First let's just implement these benefits.
The first one was on the connection on an unconnected.
OK.
This is the first phase which is actually needed is met with again just like in here on connected and
here you can see that the autocomplete feature of Android studio is helping me to use this method.
I didn't just put that interview on your keyboard.
So now you have this method the second method is what is let me actually just click on this class.
You just tap it in order to see the second.
This is the second method on connection suspended.
So let's go to the main activity class and just type in here on connection suspended.
Right.
So again I actually implemented these two misfits here right inside the main activity class.
So again we have errors and this error is actually guarding to these on connections fatally center.
So let's go to these tartlets click on the top here again.
And now you can see these on connection fed listener.
And in this listener we have this method of connection.
So this means this is going to be called whenever that the connection to actually to the location is
actually fake.
This means that we cannot access the location.
So this is going to be called.
So let's actually click on it.
This could go to the main activity class and let's implement this in effect on a connection faith on
connection for it.
So we also implemented this move.
And now you can see that we have no errors right.
Everything is fine and we have no errors yet.
Right.
Because we implemented these require if it's inside our main activity class.
So that's it.
So now it's time to create another constant.
This is called request court.
OK.
So inside this class and below this line of code we do with this constant attack.
Let's create another constant.
But this time it is going to be private because only the main activity class needs to know about this
constant.
So private static.
OK.
Final This is a concentrate it and the name is going to be chapiter lies.
Ok this is a convention.
It is not necessary to be tied capitalized but it is a convention in Java.
So here's a step in here a request quote requests underlined quote and assign the value of 1000 to this
constant.
OK so that's it.
Now let's create some variables.
Let's declare somebody else here in say that main activity class and then later we're going to initialize
them.
So the first variable is going to be actually private and it is going to be off the Google API client.
OK.
And the name is going to be just Google Play client semi-colon.
So here just declared a disparity of type Google API client.
Now it's time to actually declare the second valuable so just open private.
Again this is actually a private variable and it is going to be off site location and that location
like this class actually holds those coordinates that they actually talk to you about the latitude and
longitude.
OK.
So it is it.
Let me ask you to just hold the under control chair.
And if I click on location you can see that this class is the location and you can see that we have
the form at degrees.
So all these constants here let me just close this fight here let me also close the school API land
class and here just for the name.
Just type in his location semicolon.
Now let's declare another variable of type takes view and this is going to be the location.
So this is the variable that is going to hold the takes you object that we have inside our view right
now.
Let's go to the uncreate method.
First of all let's initialize RTX the location value.
So just typing here takes the location assignment operator and put a pair of practices in order to cast
this object to a text view object find view by ID or that ID that T X the location semi-colon.
So now it's time to initialize our Google API client actually instance.
So just typing here Google API client assignment operator.
So here I'm going to initialize this value right.
So now I'm going to create the actual object.
The actual instance of the Google API client and here I want to actually register this main activity
class in order to be able to receive the connection messages the faked messages that the Google API
client actually sense.
So let's just open a new Google API client so as you can see it's going to actually just prompt you
to choose this option.
Don't choose this option just typing as I do here.
Google API client.
So here you can see that we have Google API client dot builder and inside Apprentice's because this
classmate activity is going to be registered as a class to receive the messages that the Google IPO
claimed actually sent.
So we are going to pass the main activity that this as the context.
OK so now I'm going to actually call some efforts here to just put a new line here just at present and
tell Junior if you would in order to create any light and just I mean he had that at connection callbacks.
So because again I'm going to register this activity as the listener.
So I'm going to pass the context.
Main activity that this OK.
Again put us another new line here as you can see we are calling some misfits here just one after the
other.
OK.
So it is necessary because first we are going to actually get the quality Google pick a client instance
and we we can actually call this if it's on that instance first we are calling this ad connection callbacks
and that we are going to say that ad actually connection fatally center.
So again this class is going to be the class that is going to actually receive the fatalists and their
messages.
Right.
So if the connection is break this glass is going to receive that message some inactivity that this
light and then put another new light here.
And a final method that we are going to call on these Google API client and then so as you can see here
you are creating that instance and we are calling this misfit on that instance and we are calling this
move it on that instance.
Right.
Let's create the final It's actually called the final Meffert on that call API in instance.
So just they can hear that at API at API as you can see we call this move so inside the prentices we
need to pass some arguments.
So inside the practices of this ad API if just type in your location services that API.
Ok so its going actually to give us the location services that API.
And then we can say that bit semi-colon.
Right.
Make sure to actually call the bill here on this location services that API here and now is going to
build that.
Actually the location services API and then we are going to be able to get the messages the location
right.
So thats it.