1
00:00:00,180 --> 00:00:07,800
So now you may ask that so what happens after the use that has actually interacted with an other intent

2
00:00:08,160 --> 00:00:14,760
in order to actually be able to access the Google Play services in order to sign in or install the Google

3
00:00:14,760 --> 00:00:15,760
Play services.

4
00:00:16,020 --> 00:00:22,940
So after that we want this application to be able to actually try connecting again.

5
00:00:22,950 --> 00:00:28,140
So in order to do that we need to actually overwrite an activity result it.

6
00:00:28,350 --> 00:00:34,810
So after the Adian curly brace of this connection failed method I want to overwrite on activity resolved

7
00:00:34,810 --> 00:00:39,960
with if it's just they've been here on activity resolved.

8
00:00:40,290 --> 00:00:42,970
So just choose this method and that person entered general keyboard.

9
00:00:43,140 --> 00:00:48,110
So first of all you can see that the Smurfette actually accepts free arguments requests quote result

10
00:00:48,160 --> 00:00:50,650
quote and the data which is of the intent.

11
00:00:50,820 --> 00:00:56,250
And then at first it's called the super version of this method is going to call them if it is on the

12
00:00:56,250 --> 00:00:59,740
superclass so superb that unactivated is out.

13
00:00:59,760 --> 00:01:04,080
And then this can actually pass these arguments here in order to initialize an activity result of the

14
00:01:04,080 --> 00:01:04,710
superclass.

15
00:01:04,850 --> 00:01:10,680
OK so far for after this line of code we want to actually put our own quotes here.

16
00:01:10,680 --> 00:01:15,140
So here I can create an if statement if I request code.

17
00:01:15,180 --> 00:01:20,120
So we get the request code from this argument the first argument of this on activity resolve method.

18
00:01:20,310 --> 00:01:26,730
If request code is equal to the request quote that we have inside our class.

19
00:01:26,850 --> 00:01:33,090
So notice that we actually use the sequence code here in order to interact with another intent in order

20
00:01:33,090 --> 00:01:36,920
to be able to sign in to Google Play services or install the Google Play services.

21
00:01:36,920 --> 00:01:39,220
So look at this line of Cahir number 69.

22
00:01:39,320 --> 00:01:41,870
We can see that inside is tribal touch.

23
00:01:42,050 --> 00:01:48,480
I want to actually start a new resolution in order to solve the problem so you can see that I use this

24
00:01:48,480 --> 00:01:49,080
request.

25
00:01:49,110 --> 00:01:55,110
So you want to actually use the same request code in order to be able to actually identify that the

26
00:01:55,110 --> 00:02:01,050
user has interacted with other entities in order to solve that specific problem of actually accessing

27
00:02:01,050 --> 00:02:02,600
the Google Play services.

28
00:02:02,610 --> 00:02:04,500
So I put an ontological.

29
00:02:04,500 --> 00:02:10,490
Operator And and then here I can see the results code is equal to.

30
00:02:10,520 --> 00:02:11,090
Result.

31
00:02:11,190 --> 00:02:13,970
OK so just let this one result.

32
00:02:13,980 --> 00:02:14,790
OK.

33
00:02:14,940 --> 00:02:18,380
This means that everything event actually fine.

34
00:02:18,630 --> 00:02:21,900
So the result code is actually OK only in that case.

35
00:02:21,900 --> 00:02:27,800
Inside this if statement I can't say Google API client dot connect.

36
00:02:27,810 --> 00:02:30,940
So it can actually try connecting it to the Google API.

37
00:02:31,110 --> 00:02:32,260
Google API client.

38
00:02:32,280 --> 00:02:32,830
OK.

39
00:02:33,150 --> 00:02:37,130
So we call this method here inside this Mefford and I can with the result.

40
00:02:37,140 --> 00:02:43,460
And we want to also call this connect Meffert of the Google API client India and so on On-Star Smurfette

41
00:02:43,470 --> 00:02:47,610
this is actually one of the Android lifecycle Mefford that is going to be called after the uncreate

42
00:02:47,610 --> 00:02:47,910
method.

43
00:02:47,910 --> 00:02:55,200
So after the NDA curly brace of this activity result here I want to actually call the conics Smurfette

44
00:02:55,290 --> 00:02:56,820
of the Google Play client.

45
00:02:56,820 --> 00:03:01,380
So when I actually called the connect method of the Google Play API a client is going actually called

46
00:03:01,380 --> 00:03:03,880
the uncorrect method here unconnected here.

47
00:03:03,940 --> 00:03:04,530
Right.

48
00:03:04,590 --> 00:03:13,920
If there is going actually to try connecting to the Google API client and if it was actually successful

49
00:03:14,020 --> 00:03:22,080
it was actually successfully managed to connect to the Google API client in order to get the location.

50
00:03:22,470 --> 00:03:27,290
Then it's going to actually call this unconnected if Israelis can actually send back some efforts.

51
00:03:27,330 --> 00:03:30,260
If it was successful it is going to call unconnected.

52
00:03:30,420 --> 00:03:36,300
If it was actually suspended it is going to call on connections suspended if it was actually if it actually

53
00:03:36,300 --> 00:03:40,300
failed to connect to the Google Play client or for any reasons.

54
00:03:40,350 --> 00:03:42,000
Going to call on connection fate.

55
00:03:42,120 --> 00:03:42,690
OK.

56
00:03:42,870 --> 00:03:51,350
So here after the end in curly brace of this unactivated result here I can just step in and start over

57
00:03:51,510 --> 00:03:52,040
with.

58
00:03:52,080 --> 00:03:58,020
So after this line of court that actually caused unstop on the block last year I can't just say Google

59
00:03:58,170 --> 00:04:05,400
if let's actually create an if statement if Google API client is not equal to null then in that case

60
00:04:05,460 --> 00:04:07,750
I can say google it for a client that can.

61
00:04:07,860 --> 00:04:08,460
Right.

62
00:04:08,460 --> 00:04:16,230
So now it's time to run our application on our actual Android device in order to get the physical location

63
00:04:16,230 --> 00:04:16,930
of the device.

64
00:04:16,950 --> 00:04:21,490
But for now I just want to show you that how it is how it's going to work on the emulator.

65
00:04:21,510 --> 00:04:28,440
So let's actually come right here and now this is my actual device HTC Desire but no one to actually

66
00:04:28,440 --> 00:04:36,560
test my application on the emulator Nexus 6 API 25 Android 7.0 1.1 API 25.

67
00:04:36,780 --> 00:04:38,830
Let's select this one and then just click on OK.

68
00:04:38,850 --> 00:04:44,030
So now you can see that our application is actually running on the simulator so for now.

69
00:04:44,040 --> 00:04:46,740
First of all let's look at the text of this text.

70
00:04:46,740 --> 00:04:52,620
It says This app is not allowed to access the location so it can actually show us this message allow

71
00:04:52,880 --> 00:04:57,500
GPS location app to access these devices location.

72
00:04:57,530 --> 00:04:59,680
Can I ask you this question.

73
00:04:59,680 --> 00:05:04,710
So click can allow it's going to allow this app to access the location it's going to allow.

74
00:05:04,890 --> 00:05:10,350
Now you can see that this app is actually allowed to access the location but nothing happened here.

75
00:05:10,350 --> 00:05:11,040
Why.

76
00:05:11,040 --> 00:05:13,580
Because we called it the Smurfette.

77
00:05:13,660 --> 00:05:17,950
This connect with it on this Google API Client ID and start prefet right.

78
00:05:18,000 --> 00:05:22,220
So the unstacking if this is the Meffert that is going to be called after the uncreate MF'er.

79
00:05:22,440 --> 00:05:28,200
So now that if it is already called its not going to be called again sooner or later actually we need

80
00:05:28,200 --> 00:05:30,170
to just close this app now.

81
00:05:30,180 --> 00:05:31,300
Let's click on this.

82
00:05:31,320 --> 00:05:37,650
I can here in order to actually show all these devices now let me just close all this up.

83
00:05:37,770 --> 00:05:44,100
Now let's actually go to the applications here let's find our application G.P.A. application app.

84
00:05:44,130 --> 00:05:48,210
Now you can see that it says this app is not able to access the location now.

85
00:05:48,210 --> 00:05:49,140
Try again later.

86
00:05:49,200 --> 00:05:50,340
What does this mean.

87
00:05:50,370 --> 00:05:58,520
This means that this emulator cannot access the actual location of this device.

88
00:05:58,590 --> 00:06:02,650
We are testing this application on an emulator not on not a physical device.

89
00:06:02,820 --> 00:06:09,210
So you must run your application on your physical Android device in order to see the coordinates the

90
00:06:09,210 --> 00:06:10,970
latitude and longitude.

91
00:06:10,980 --> 00:06:16,410
So now I'm going to actually tested on my own device in order to see if this works or not.

92
00:06:16,410 --> 00:06:22,730
So now let me just click on one button and this time I want to choose my own actual Android device.

93
00:06:22,740 --> 00:06:23,740
Let's click on OK.

94
00:06:23,910 --> 00:06:29,370
So now that I actually ran my Android application on my PC called Android device I cannot show you that

95
00:06:29,370 --> 00:06:33,390
here but I can see the coordinates the latitude and longitude.

96
00:06:33,570 --> 00:06:39,090
So make sure to test your app on your physical Android device.

97
00:06:39,120 --> 00:06:41,600
So in order in order to see the latitude and longitude.

