1
00:00:00,450 --> 00:00:09,260
So here this class main activity must conform or implement the unkind action callback.

2
00:00:09,270 --> 00:00:13,950
Actually the interface so here main activity extends app comp. activity.

3
00:00:13,950 --> 00:00:20,860
Now after this app compactus they can here implements Google API client.

4
00:00:20,950 --> 00:00:22,040
OK so this is really important.

5
00:00:22,050 --> 00:00:24,710
If you can't access this will it be a client.

6
00:00:24,720 --> 00:00:29,240
That means that inside the bill create a file the applet will get built with that file.

7
00:00:29,340 --> 00:00:32,760
You did not actually put this line of code here inside these dependencies plug.

8
00:00:32,820 --> 00:00:33,220
OK.

9
00:00:33,390 --> 00:00:35,000
So let's go to the main of the class.

10
00:00:35,070 --> 00:00:41,650
So Google API client dot Google API client dots connection callbacks.

11
00:00:41,760 --> 00:00:45,470
OK collection callbacks so we must conform to this interface.

12
00:00:45,540 --> 00:00:49,650
Just press on until your keyboard and they put a comma here.

13
00:00:49,780 --> 00:00:58,530
So you need to I need to also conform to another interface and that interface is Google API client that's

14
00:00:59,220 --> 00:01:02,360
actually on connection failed listener.

15
00:01:02,550 --> 00:01:03,010
OK.

16
00:01:03,060 --> 00:01:06,390
We must actually conform to these interfaces.

17
00:01:06,390 --> 00:01:08,700
We must actually implement these interfaces.

18
00:01:08,700 --> 00:01:15,100
Google API client connection codecs and Google API client that and connection failed listeners.

19
00:01:15,600 --> 00:01:21,630
So now that we actually conformed to these interfaces now that we implemented these interfaces we must

20
00:01:22,050 --> 00:01:26,710
actually implement them Misfit's that are inside of these interfaces.

21
00:01:26,730 --> 00:01:32,250
So if we actually hold down to the common key on my keyboard so if you are using a Windows machine you

22
00:01:32,250 --> 00:01:37,920
can actually hold down the control key on your keyboard and just click on this connection callbacks

23
00:01:37,920 --> 00:01:38,510
here.

24
00:01:38,670 --> 00:01:42,360
As you can see it guided me to this Google API client class.

25
00:01:42,450 --> 00:01:44,330
You can see that we have this interface here.

26
00:01:44,340 --> 00:01:50,580
Inside is a class you can see that it says public interface connection callbacks.

27
00:01:50,640 --> 00:01:51,370
Right.

28
00:01:51,420 --> 00:01:58,200
So we have these two integer values and cause service disconnected int cause network lost and we have

29
00:01:58,200 --> 00:02:02,770
the Smurfit unconnected on connection suspended right.

30
00:02:02,790 --> 00:02:07,590
This means that we must implement these two methods inside our main activity class because we actually

31
00:02:07,590 --> 00:02:11,250
implemented this interface this unconscious callbacks interface.

32
00:02:11,250 --> 00:02:11,770
Right.

33
00:02:11,850 --> 00:02:19,200
So this unconvicted if it is going to be called whenever that we actually can connect to that location

34
00:02:19,200 --> 00:02:23,070
services in order to get the user's location or any others any other location.

35
00:02:23,070 --> 00:02:23,600
Right.

36
00:02:23,880 --> 00:02:25,770
And we have these connections suspended.

37
00:02:25,780 --> 00:02:31,680
So this is going to be called whenever something happens when ever a problem is actually occurred and

38
00:02:31,680 --> 00:02:34,480
we cannot currently access the location.

39
00:02:34,530 --> 00:02:36,300
So it is going to be suspended.

40
00:02:36,600 --> 00:02:39,700
So let's go back to the main activity class here.

41
00:02:39,750 --> 00:02:41,740
First let's just implement these benefits.

42
00:02:41,760 --> 00:02:47,040
The first one was on the connection on an unconnected.

43
00:02:47,040 --> 00:02:47,250
OK.

44
00:02:47,280 --> 00:02:53,160
This is the first phase which is actually needed is met with again just like in here on connected and

45
00:02:53,160 --> 00:02:58,280
here you can see that the autocomplete feature of Android studio is helping me to use this method.

46
00:02:58,280 --> 00:03:00,560
I didn't just put that interview on your keyboard.

47
00:03:00,960 --> 00:03:06,520
So now you have this method the second method is what is let me actually just click on this class.

48
00:03:06,510 --> 00:03:08,260
You just tap it in order to see the second.

49
00:03:08,280 --> 00:03:10,480
This is the second method on connection suspended.

50
00:03:10,620 --> 00:03:16,110
So let's go to the main activity class and just type in here on connection suspended.

51
00:03:16,380 --> 00:03:16,820
Right.

52
00:03:16,830 --> 00:03:21,840
So again I actually implemented these two misfits here right inside the main activity class.

53
00:03:21,840 --> 00:03:28,020
So again we have errors and this error is actually guarding to these on connections fatally center.

54
00:03:28,140 --> 00:03:31,960
So let's go to these tartlets click on the top here again.

55
00:03:32,310 --> 00:03:35,530
And now you can see these on connection fed listener.

56
00:03:35,640 --> 00:03:38,380
And in this listener we have this method of connection.

57
00:03:38,400 --> 00:03:44,910
So this means this is going to be called whenever that the connection to actually to the location is

58
00:03:44,910 --> 00:03:45,610
actually fake.

59
00:03:45,630 --> 00:03:47,980
This means that we cannot access the location.

60
00:03:48,000 --> 00:03:49,230
So this is going to be called.

61
00:03:49,260 --> 00:03:50,580
So let's actually click on it.

62
00:03:50,580 --> 00:03:56,460
This could go to the main activity class and let's implement this in effect on a connection faith on

63
00:03:56,460 --> 00:03:57,740
connection for it.

64
00:03:57,870 --> 00:03:59,470
So we also implemented this move.

65
00:03:59,490 --> 00:04:01,760
And now you can see that we have no errors right.

66
00:04:01,770 --> 00:04:04,100
Everything is fine and we have no errors yet.

67
00:04:04,110 --> 00:04:04,690
Right.

68
00:04:04,740 --> 00:04:09,580
Because we implemented these require if it's inside our main activity class.

69
00:04:09,780 --> 00:04:10,800
So that's it.

70
00:04:10,800 --> 00:04:14,370
So now it's time to create another constant.

71
00:04:14,460 --> 00:04:16,080
This is called request court.

72
00:04:16,140 --> 00:04:16,650
OK.

73
00:04:16,800 --> 00:04:20,640
So inside this class and below this line of code we do with this constant attack.

74
00:04:20,640 --> 00:04:22,100
Let's create another constant.

75
00:04:22,110 --> 00:04:27,360
But this time it is going to be private because only the main activity class needs to know about this

76
00:04:27,360 --> 00:04:28,000
constant.

77
00:04:28,080 --> 00:04:30,050
So private static.

78
00:04:30,190 --> 00:04:30,510
OK.

79
00:04:30,510 --> 00:04:35,700
Final This is a concentrate it and the name is going to be chapiter lies.

80
00:04:35,730 --> 00:04:36,800
Ok this is a convention.

81
00:04:36,810 --> 00:04:41,330
It is not necessary to be tied capitalized but it is a convention in Java.

82
00:04:41,550 --> 00:04:49,500
So here's a step in here a request quote requests underlined quote and assign the value of 1000 to this

83
00:04:49,500 --> 00:04:50,400
constant.

84
00:04:50,410 --> 00:04:52,740
OK so that's it.

85
00:04:52,740 --> 00:04:55,890
Now let's create some variables.

86
00:04:55,890 --> 00:05:00,690
Let's declare somebody else here in say that main activity class and then later we're going to initialize

87
00:05:00,690 --> 00:05:01,260
them.

88
00:05:01,260 --> 00:05:07,540
So the first variable is going to be actually private and it is going to be off the Google API client.

89
00:05:07,720 --> 00:05:08,220
OK.

90
00:05:08,340 --> 00:05:10,770
And the name is going to be just Google Play client semi-colon.

91
00:05:10,770 --> 00:05:15,240
So here just declared a disparity of type Google API client.

92
00:05:15,240 --> 00:05:20,770
Now it's time to actually declare the second valuable so just open private.

93
00:05:20,770 --> 00:05:26,140
Again this is actually a private variable and it is going to be off site location and that location

94
00:05:26,170 --> 00:05:31,930
like this class actually holds those coordinates that they actually talk to you about the latitude and

95
00:05:31,930 --> 00:05:32,480
longitude.

96
00:05:32,500 --> 00:05:33,140
OK.

97
00:05:33,220 --> 00:05:33,910
So it is it.

98
00:05:33,970 --> 00:05:36,010
Let me ask you to just hold the under control chair.

99
00:05:36,040 --> 00:05:41,170
And if I click on location you can see that this class is the location and you can see that we have

100
00:05:41,170 --> 00:05:42,370
the form at degrees.

101
00:05:42,370 --> 00:05:49,120
So all these constants here let me just close this fight here let me also close the school API land

102
00:05:49,120 --> 00:05:53,680
class and here just for the name.

103
00:05:53,680 --> 00:05:56,030
Just type in his location semicolon.

104
00:05:56,110 --> 00:06:02,020
Now let's declare another variable of type takes view and this is going to be the location.

105
00:06:02,020 --> 00:06:07,270
So this is the variable that is going to hold the takes you object that we have inside our view right

106
00:06:07,790 --> 00:06:08,190
now.

107
00:06:08,190 --> 00:06:09,850
Let's go to the uncreate method.

108
00:06:09,850 --> 00:06:13,100
First of all let's initialize RTX the location value.

109
00:06:13,120 --> 00:06:18,700
So just typing here takes the location assignment operator and put a pair of practices in order to cast

110
00:06:18,730 --> 00:06:27,800
this object to a text view object find view by ID or that ID that T X the location semi-colon.

111
00:06:28,180 --> 00:06:33,190
So now it's time to initialize our Google API client actually instance.

112
00:06:33,430 --> 00:06:37,750
So just typing here Google API client assignment operator.

113
00:06:37,900 --> 00:06:40,050
So here I'm going to initialize this value right.

114
00:06:40,060 --> 00:06:42,330
So now I'm going to create the actual object.

115
00:06:42,340 --> 00:06:48,430
The actual instance of the Google API client and here I want to actually register this main activity

116
00:06:48,430 --> 00:06:56,020
class in order to be able to receive the connection messages the faked messages that the Google API

117
00:06:56,050 --> 00:06:58,070
client actually sense.

118
00:06:58,090 --> 00:07:05,860
So let's just open a new Google API client so as you can see it's going to actually just prompt you

119
00:07:05,860 --> 00:07:06,900
to choose this option.

120
00:07:06,910 --> 00:07:09,340
Don't choose this option just typing as I do here.

121
00:07:09,340 --> 00:07:12,690
Google API client.

122
00:07:13,270 --> 00:07:21,310
So here you can see that we have Google API client dot builder and inside Apprentice's because this

123
00:07:21,310 --> 00:07:27,350
classmate activity is going to be registered as a class to receive the messages that the Google IPO

124
00:07:27,420 --> 00:07:29,430
claimed actually sent.

125
00:07:29,440 --> 00:07:33,830
So we are going to pass the main activity that this as the context.

126
00:07:33,880 --> 00:07:40,670
OK so now I'm going to actually call some efforts here to just put a new line here just at present and

127
00:07:40,670 --> 00:07:47,070
tell Junior if you would in order to create any light and just I mean he had that at connection callbacks.

128
00:07:47,290 --> 00:07:51,450
So because again I'm going to register this activity as the listener.

129
00:07:51,670 --> 00:07:53,200
So I'm going to pass the context.

130
00:07:53,200 --> 00:07:55,610
Main activity that this OK.

131
00:07:55,720 --> 00:08:02,770
Again put us another new line here as you can see we are calling some misfits here just one after the

132
00:08:02,770 --> 00:08:03,170
other.

133
00:08:03,250 --> 00:08:03,770
OK.

134
00:08:03,880 --> 00:08:08,890
So it is necessary because first we are going to actually get the quality Google pick a client instance

135
00:08:08,980 --> 00:08:14,500
and we we can actually call this if it's on that instance first we are calling this ad connection callbacks

136
00:08:14,860 --> 00:08:19,620
and that we are going to say that ad actually connection fatally center.

137
00:08:19,750 --> 00:08:25,120
So again this class is going to be the class that is going to actually receive the fatalists and their

138
00:08:25,120 --> 00:08:25,880
messages.

139
00:08:25,900 --> 00:08:26,530
Right.

140
00:08:26,620 --> 00:08:30,490
So if the connection is break this glass is going to receive that message some inactivity that this

141
00:08:31,180 --> 00:08:33,980
light and then put another new light here.

142
00:08:34,210 --> 00:08:40,170
And a final method that we are going to call on these Google API client and then so as you can see here

143
00:08:40,200 --> 00:08:45,400
you are creating that instance and we are calling this misfit on that instance and we are calling this

144
00:08:45,400 --> 00:08:46,510
move it on that instance.

145
00:08:46,510 --> 00:08:46,980
Right.

146
00:08:47,050 --> 00:08:52,780
Let's create the final It's actually called the final Meffert on that call API in instance.

147
00:08:52,810 --> 00:09:01,120
So just they can hear that at API at API as you can see we call this move so inside the prentices we

148
00:09:01,120 --> 00:09:02,740
need to pass some arguments.

149
00:09:02,740 --> 00:09:10,420
So inside the practices of this ad API if just type in your location services that API.

150
00:09:10,860 --> 00:09:14,540
Ok so its going actually to give us the location services that API.

151
00:09:14,560 --> 00:09:18,000
And then we can say that bit semi-colon.

152
00:09:18,430 --> 00:09:18,840
Right.

153
00:09:18,850 --> 00:09:24,370
Make sure to actually call the bill here on this location services that API here and now is going to

154
00:09:24,370 --> 00:09:25,950
build that.

155
00:09:26,050 --> 00:09:32,500
Actually the location services API and then we are going to be able to get the messages the location

156
00:09:32,500 --> 00:09:33,100
right.

157
00:09:33,280 --> 00:09:33,840
So thats it.

