1
00:00:00,360 --> 00:00:06,850
So now that we have the Smurfette actually does show the use of location here we need to actually call

2
00:00:06,840 --> 00:00:09,510
it from these unconnected method here.

3
00:00:09,600 --> 00:00:14,910
So let's go inside the curly braces of this unconnected method and here I just need to type in here

4
00:00:14,950 --> 00:00:22,470
show the user location and let's actually also lock some values here.

5
00:00:22,470 --> 00:00:28,530
So just type in your log that's the and then actually the.

6
00:00:29,000 --> 00:00:30,560
And then just put a pair of parentheses first.

7
00:00:30,570 --> 00:00:32,170
We need to actually pass the tach.

8
00:00:32,240 --> 00:00:37,680
So we already created a value of type tags inside this main activity class to just put that here.

9
00:00:37,910 --> 00:00:42,600
And as the second argument we can actually just put two quotes here and we can say connected.

10
00:00:42,800 --> 00:00:44,690
Or we can say we can.

11
00:00:44,870 --> 00:00:45,840
We are connected.

12
00:00:45,860 --> 00:00:48,100
We are connected.

13
00:00:49,450 --> 00:00:55,640
To their users location users location.

14
00:00:55,890 --> 00:00:56,580
Right.

15
00:00:56,640 --> 00:00:57,780
Semicolon.

16
00:00:57,780 --> 00:00:58,680
So that's it.

17
00:00:58,890 --> 00:01:03,150
And now we have also these two methods of connection suspended.

18
00:01:03,150 --> 00:01:05,790
So let's go inside this connection suspended method.

19
00:01:06,000 --> 00:01:11,580
And here let's also lug some values so lug that the inside Apprentice's.

20
00:01:11,580 --> 00:01:17,100
First we need to pass the pack come up and as the second argument I can just put two coats which is

21
00:01:17,100 --> 00:01:18,180
a five string right.

22
00:01:18,300 --> 00:01:23,290
And here I can see the connection is suspended.

23
00:01:23,310 --> 00:01:31,290
The connection is suspended semi-colon and we have this method of connection failed.

24
00:01:31,380 --> 00:01:31,770
OK.

25
00:01:31,830 --> 00:01:33,710
So let's go inside the curly braces of this method.

26
00:01:33,710 --> 00:01:37,300
So this method is going to be called when the connection is actually failed.

27
00:01:37,370 --> 00:01:42,290
When the user is not actually able to get the location and the application is not able to get a location.

28
00:01:42,390 --> 00:01:46,620
In that case it's going to this if it is going to be called on connection failed.

29
00:01:46,620 --> 00:01:49,290
So let's actually lock somebody like that.

30
00:01:49,340 --> 00:01:53,270
The as the first argument we need to pass the comma.

31
00:01:53,430 --> 00:01:57,950
And as the second argument I can just pass this value.

32
00:01:58,500 --> 00:02:00,420
The connection failed.

33
00:02:00,420 --> 00:02:01,590
Right semicolon.

34
00:02:01,770 --> 00:02:05,590
So let's create some if statements here inside the Smurfit.

35
00:02:05,790 --> 00:02:12,420
So here first let me tell you that the user must have access to the Google Play services in order to

36
00:02:12,420 --> 00:02:16,300
actually use the capabilities of this application in order to access their location.

37
00:02:16,350 --> 00:02:16,860
OK.

38
00:02:17,160 --> 00:02:23,700
So if the user cannot access to Google Play services or if the user is not signed in or if they use

39
00:02:23,700 --> 00:02:27,580
that actually doesn't have any access to Google Play services.

40
00:02:27,840 --> 00:02:29,980
In that case the connection may be fake.

41
00:02:30,000 --> 00:02:30,410
OK.

42
00:02:30,540 --> 00:02:33,000
So we don't actually check for that condition.

43
00:02:33,000 --> 00:02:38,880
We want to prompt the user to actually sign in in Google Play services so that the user can actually

44
00:02:38,880 --> 00:02:40,320
continue using this application.

45
00:02:40,320 --> 00:02:44,640
First let me actually show you the emulator that the documentation actually.

46
00:02:44,880 --> 00:02:46,910
So you can see this connection result class.

47
00:02:46,920 --> 00:02:47,430
OK.

48
00:02:47,670 --> 00:02:53,070
So first let me show you the Android studio and you can see that this method of connection failed actually

49
00:02:53,370 --> 00:02:54,700
has an argument.

50
00:02:54,720 --> 00:02:55,960
This parameter here.

51
00:02:56,130 --> 00:02:56,650
Right.

52
00:02:56,670 --> 00:03:00,730
And the data type of this argument is actually the connection result.

53
00:03:00,750 --> 00:03:02,400
This is the connection result class.

54
00:03:02,490 --> 00:03:03,910
So let's go to the documentation.

55
00:03:03,950 --> 00:03:08,240
You can see this class and it says Puplick fine and class connection result.

56
00:03:08,260 --> 00:03:09,880
Accent's object.

57
00:03:09,960 --> 00:03:16,320
So this class extends the object class and implements the parsable actually interface right.

58
00:03:16,320 --> 00:03:22,830
So let's actually look at this description it says contains all possible error codes for when a client

59
00:03:22,890 --> 00:03:26,130
or client refers to the application that want to access them.

60
00:03:26,160 --> 00:03:32,940
Actually the Google Play services our client fails to connect to Google Play services these error codes

61
00:03:33,030 --> 00:03:35,200
are used by Google API client.

62
00:03:35,220 --> 00:03:37,430
That connection failed listener.

63
00:03:37,560 --> 00:03:38,140
Right.

64
00:03:38,160 --> 00:03:40,720
So this is actually familiar to you.

65
00:03:40,800 --> 00:03:44,100
So now let's actually go back to android studio here.

66
00:03:44,100 --> 00:03:45,440
So we have these arguments right.

67
00:03:45,480 --> 00:03:47,820
So let's actually to check for these kinds of errors.

68
00:03:47,820 --> 00:03:48,360
OK.

69
00:03:48,600 --> 00:03:54,940
Now I can't say if connections result that has resolution.

70
00:03:55,140 --> 00:03:59,090
So this has resolution whether actually to return a value of a boolean.

71
00:03:59,100 --> 00:04:04,170
So here I am actually fed into this connection result and I am accessing a method that is actually this

72
00:04:04,170 --> 00:04:07,760
is actually an instance of this connection resolved has a resolution.

73
00:04:07,770 --> 00:04:13,680
So let's go back to the under documentation and in and here let's actually search for has a resolution

74
00:04:13,690 --> 00:04:14,320
method here.

75
00:04:14,340 --> 00:04:14,880
Right.

76
00:04:14,880 --> 00:04:20,250
So in order to test for a specific keyword here instead of a page if you are using a Mac you just need

77
00:04:20,250 --> 00:04:24,340
to hold down the command key on your keyboard and then press and if key on your keyboard.

78
00:04:24,630 --> 00:04:29,400
And if you are using a Windows machine you just need to hold down the control on your keyboard and then

79
00:04:29,400 --> 00:04:31,170
press on if key on your keyboard.

80
00:04:31,410 --> 00:04:35,960
So here I can search for has resolution resolution.

81
00:04:36,330 --> 00:04:37,690
Right here it is.

82
00:04:37,770 --> 00:04:40,770
It actually found free results here.

83
00:04:40,770 --> 00:04:41,990
The first one is this one.

84
00:04:42,180 --> 00:04:43,050
You can see it is public.

85
00:04:43,080 --> 00:04:44,100
If it's somebody Paulian.

86
00:04:44,100 --> 00:04:51,920
So the return type of this Mfat is boolean and it returns true if calling starts with resolution for

87
00:04:51,930 --> 00:04:58,040
result will start any intense requiring user interaction.

88
00:04:58,050 --> 00:05:06,170
So this means that it's going to actually give us if this method has resolution retains the value true.

89
00:05:06,180 --> 00:05:07,600
Let me show you the Andrew studio here.

90
00:05:07,650 --> 00:05:09,110
We are looking for the value to right.

91
00:05:09,120 --> 00:05:12,540
Here we are saying that if the condition is that that has a resolution.

92
00:05:12,810 --> 00:05:15,980
So because this is should return the a value of the bullion.

93
00:05:16,020 --> 00:05:18,170
Here we are looking for that for the true value.

94
00:05:18,220 --> 00:05:20,870
It is going to return the value true.

95
00:05:21,000 --> 00:05:26,460
Let me show you the emulator then it's going to actually open and intent and other intent in order to

96
00:05:26,460 --> 00:05:33,780
prompt the user to actually do for example signing to Google Play services or for example or just install

97
00:05:33,780 --> 00:05:35,030
the Google Play services.

98
00:05:35,040 --> 00:05:38,800
So that's what this has it has a resolution means.

99
00:05:38,900 --> 00:05:39,450
OK.

100
00:05:39,510 --> 00:05:40,810
It is actually true.

101
00:05:40,980 --> 00:05:45,060
Then we can i should open and close dismiss this statement by using the curly braces.

102
00:05:45,230 --> 00:05:51,610
I can't just referred to this argument connection result that start resolution for result.

103
00:05:51,780 --> 00:05:52,230
OK.

104
00:05:52,320 --> 00:05:55,560
And this left accepts two arguments the first one is the context.

105
00:05:55,670 --> 00:05:59,950
Main activity that this and the second one is the request the court.

106
00:06:00,000 --> 00:06:01,660
So it is an integer right.

107
00:06:01,680 --> 00:06:04,680
We already have valuable of type integer.

108
00:06:04,680 --> 00:06:07,550
This is actually a constant Let me show you that this constant here.

109
00:06:07,830 --> 00:06:12,910
So here it is our request called Constant and we assigned the value 1000 to this constant right.

110
00:06:12,960 --> 00:06:14,380
So we can use it here.

111
00:06:14,400 --> 00:06:18,810
This is actually a unique value that we use for Google Play services in order to actually prompt the

112
00:06:18,810 --> 00:06:22,670
user to sign in or to install the Google Play services under device.

113
00:06:22,670 --> 00:06:29,900
So now if we actually call this method and the user would be able to sign in or do any necessary changes

114
00:06:29,900 --> 00:06:33,820
to access the Google Play services then it is going to return true.

115
00:06:34,070 --> 00:06:36,340
And the problem is going to be solved.

116
00:06:36,350 --> 00:06:40,710
OK then it's not going to actually call this connection failed method again.

117
00:06:40,790 --> 00:06:44,470
So let's pass this request here request called.

118
00:06:44,680 --> 00:06:45,280
Right.

119
00:06:45,470 --> 00:06:48,260
But here we had a problem.

120
00:06:48,410 --> 00:06:48,670
OK.

121
00:06:48,680 --> 00:06:51,380
So what is that problem hovered over this area.

122
00:06:51,380 --> 00:06:58,190
It says unhandled exception and throughout that content that intent the sender that sent intent exception.

123
00:06:58,250 --> 00:07:06,350
This means that the user's device may actually fail to for example open another intense and other activity

124
00:07:06,350 --> 00:07:11,300
to prompt the user to sign into Google to Google Play services or install the Google Play services the

125
00:07:11,310 --> 00:07:13,230
users device may actually fail to do that.

126
00:07:13,280 --> 00:07:13,600
OK.

127
00:07:13,730 --> 00:07:18,460
We need to handle that exception how we can do that by using to try catch block.

128
00:07:18,530 --> 00:07:25,280
So just typing here try and put this line of code he had inside a try block just cut and paste it here

129
00:07:25,790 --> 00:07:27,140
and then it'll handle that exception.

130
00:07:27,150 --> 00:07:34,430
So after the end curly brace of this try block I can just say catch an inside Apprentice's I can say

131
00:07:34,520 --> 00:07:35,730
acception.

132
00:07:36,020 --> 00:07:36,890
OK.

133
00:07:37,220 --> 00:07:41,690
So this is the name of this argument actually and I just want to open and close this terrible act by

134
00:07:41,690 --> 00:07:42,810
using these curly braces.

135
00:07:42,920 --> 00:07:46,110
And here I can't just say lug that D.

136
00:07:46,250 --> 00:07:48,890
And first I need to pass the patch comma.

137
00:07:49,130 --> 00:07:58,370
And here I can see that description excuse me it that stack get stack trace to strings.

138
00:07:59,090 --> 00:08:00,420
OK semicolon.

139
00:08:00,500 --> 00:08:04,950
So it can actually print some values to the log and then we can actually see what's wrong.

140
00:08:05,000 --> 00:08:05,810
OK.

141
00:08:05,840 --> 00:08:06,350
So that's it.

142
00:08:06,350 --> 00:08:09,230
We actually handle the exception.

143
00:08:09,230 --> 00:08:10,860
So this is our IF statement.

144
00:08:10,860 --> 00:08:17,930
OK so now after the end in curly brace of this if statement let's actually create an illicit statement

145
00:08:17,950 --> 00:08:21,840
so this is this statement is going to be executed if this condition actually face.

146
00:08:21,870 --> 00:08:28,280
Ok if this condition here evaluates to false and the user would not be able to access the Google Play

147
00:08:28,280 --> 00:08:32,360
services in that case we want to actually finish what those finished means.

148
00:08:32,360 --> 00:08:35,040
Finish means exit the application completely.

149
00:08:35,090 --> 00:08:40,760
The user is not is not going to be able to use this application anymore if the user is not able to access

150
00:08:40,760 --> 00:08:42,280
the Google Play services.

151
00:08:42,290 --> 00:08:49,180
So we put this as a statement and here first I can't say toast does it make text.

152
00:08:49,280 --> 00:08:53,130
First we need to pass the context main activity that this come up.

153
00:08:53,330 --> 00:08:59,780
And as the second argument we need to pass the value so I can say Google Play services Google Play services

154
00:09:01,620 --> 00:09:04,830
is not working.

155
00:09:05,280 --> 00:09:05,810
OK.

156
00:09:06,810 --> 00:09:09,110
Backseats come up.

157
00:09:09,430 --> 00:09:12,890
And as the second argument we need to specify the duration of the message that I want to show to the

158
00:09:12,890 --> 00:09:18,420
users so it is going to be actually Laune that show.

159
00:09:18,690 --> 00:09:19,250
That's it.

160
00:09:19,410 --> 00:09:25,600
And then here I am I'm just going to call Finish finish means actually is going to finish.

161
00:09:25,800 --> 00:09:27,980
It's going to go outside of this.

162
00:09:27,990 --> 00:09:34,760
I mean it is going to close this main activity and then it's going to actually finish using this app.

163
00:09:34,840 --> 00:09:36,010
So that's it.

164
00:09:36,090 --> 00:09:36,480
Now.

