So now you may ask that so what happens after the use that has actually interacted with an other intent
in order to actually be able to access the Google Play services in order to sign in or install the Google
Play services.
So after that we want this application to be able to actually try connecting again.
So in order to do that we need to actually overwrite an activity result it.
So after the Adian curly brace of this connection failed method I want to overwrite on activity resolved
with if it's just they've been here on activity resolved.
So just choose this method and that person entered general keyboard.
So first of all you can see that the Smurfette actually accepts free arguments requests quote result
quote and the data which is of the intent.
And then at first it's called the super version of this method is going to call them if it is on the
superclass so superb that unactivated is out.
And then this can actually pass these arguments here in order to initialize an activity result of the
superclass.
OK so far for after this line of code we want to actually put our own quotes here.
So here I can create an if statement if I request code.
So we get the request code from this argument the first argument of this on activity resolve method.
If request code is equal to the request quote that we have inside our class.
So notice that we actually use the sequence code here in order to interact with another intent in order
to be able to sign in to Google Play services or install the Google Play services.
So look at this line of Cahir number 69.
We can see that inside is tribal touch.
I want to actually start a new resolution in order to solve the problem so you can see that I use this
request.
So you want to actually use the same request code in order to be able to actually identify that the
user has interacted with other entities in order to solve that specific problem of actually accessing
the Google Play services.
So I put an ontological.
Operator And and then here I can see the results code is equal to.
Result.
OK so just let this one result.
OK.
This means that everything event actually fine.
So the result code is actually OK only in that case.
Inside this if statement I can't say Google API client dot connect.
So it can actually try connecting it to the Google API.
Google API client.
OK.
So we call this method here inside this Mefford and I can with the result.
And we want to also call this connect Meffert of the Google API client India and so on On-Star Smurfette
this is actually one of the Android lifecycle Mefford that is going to be called after the uncreate
method.
So after the NDA curly brace of this activity result here I want to actually call the conics Smurfette
of the Google Play client.
So when I actually called the connect method of the Google Play API a client is going actually called
the uncorrect method here unconnected here.
Right.
If there is going actually to try connecting to the Google API client and if it was actually successful
it was actually successfully managed to connect to the Google API client in order to get the location.
Then it's going to actually call this unconnected if Israelis can actually send back some efforts.
If it was successful it is going to call unconnected.
If it was actually suspended it is going to call on connections suspended if it was actually if it actually
failed to connect to the Google Play client or for any reasons.
Going to call on connection fate.
OK.
So here after the end in curly brace of this unactivated result here I can just step in and start over
with.
So after this line of court that actually caused unstop on the block last year I can't just say Google
if let's actually create an if statement if Google API client is not equal to null then in that case
I can say google it for a client that can.
Right.
So now it's time to run our application on our actual Android device in order to get the physical location
of the device.
But for now I just want to show you that how it is how it's going to work on the emulator.
So let's actually come right here and now this is my actual device HTC Desire but no one to actually
test my application on the emulator Nexus 6 API 25 Android 7.0 1.1 API 25.
Let's select this one and then just click on OK.
So now you can see that our application is actually running on the simulator so for now.
First of all let's look at the text of this text.
It says This app is not allowed to access the location so it can actually show us this message allow
GPS location app to access these devices location.
Can I ask you this question.
So click can allow it's going to allow this app to access the location it's going to allow.
Now you can see that this app is actually allowed to access the location but nothing happened here.
Why.
Because we called it the Smurfette.
This connect with it on this Google API Client ID and start prefet right.
So the unstacking if this is the Meffert that is going to be called after the uncreate MF'er.
So now that if it is already called its not going to be called again sooner or later actually we need
to just close this app now.
Let's click on this.
I can here in order to actually show all these devices now let me just close all this up.
Now let's actually go to the applications here let's find our application G.P.A. application app.
Now you can see that it says this app is not able to access the location now.
Try again later.
What does this mean.
This means that this emulator cannot access the actual location of this device.
We are testing this application on an emulator not on not a physical device.
So you must run your application on your physical Android device in order to see the coordinates the
latitude and longitude.
So now I'm going to actually tested on my own device in order to see if this works or not.
So now let me just click on one button and this time I want to choose my own actual Android device.
Let's click on OK.
So now that I actually ran my Android application on my PC called Android device I cannot show you that
here but I can see the coordinates the latitude and longitude.
So make sure to test your app on your physical Android device.
So in order in order to see the latitude and longitude.