1
00:00:00,110 --> 00:00:00,860
Hi everyone.

2
00:00:00,930 --> 00:00:04,940
So now it's actually at the our own logic to this enclave Smurfit.

3
00:00:04,950 --> 00:00:07,570
First of all it's actually create a body of the.

4
00:00:07,900 --> 00:00:10,950
And the name of this variable is going to be actually the address

5
00:00:13,520 --> 00:00:16,550
value by assignment operator.

6
00:00:16,820 --> 00:00:23,320
EDT address that get text get text that to a strange semicolon.

7
00:00:23,450 --> 00:00:24,230
Right.

8
00:00:24,350 --> 00:00:27,140
So we are actually getting the value of these edits.

9
00:00:27,160 --> 00:00:31,730
This edit the address and we are assigning the value to this address value.

10
00:00:31,730 --> 00:00:34,550
Let's create a variable of type Boolean here.

11
00:00:34,550 --> 00:00:40,110
So boolean and the name of this variable is going to be is geocoding.

12
00:00:40,250 --> 00:00:45,770
So first let me actually tell you what is a joke coding coding.

13
00:00:46,100 --> 00:00:46,760
Right.

14
00:00:46,820 --> 00:00:48,800
So let me actually uncapitalized this.

15
00:00:48,800 --> 00:00:52,120
See assignment operator.

16
00:00:52,240 --> 00:00:53,210
True.

17
00:00:53,440 --> 00:00:54,940
So what is geocoding.

18
00:00:54,980 --> 00:01:03,310
Geocoding is the process of converting the latitude and longitude coordinates to an actual address value

19
00:01:03,310 --> 00:01:05,640
that is actually human readable right.

20
00:01:05,640 --> 00:01:12,490
So let me repeat again the geocoding process is going to convert the latitude and longitude coordinates

21
00:01:12,910 --> 00:01:15,350
to our human readable text.

22
00:01:15,370 --> 00:01:17,420
So that's called geocoding.

23
00:01:17,710 --> 00:01:19,740
And we created a boolean value of N here.

24
00:01:19,780 --> 00:01:21,230
The name is is geocoding.

25
00:01:21,250 --> 00:01:24,690
And initially I was saying the value true to this value.

26
00:01:25,030 --> 00:01:30,540
So now we need a variable in order to hold that destination location address.

27
00:01:30,550 --> 00:01:32,400
So let's scroll to the top here.

28
00:01:32,410 --> 00:01:34,500
This is going to be an instance variable.

29
00:01:34,810 --> 00:01:39,940
So let's actually declare it inside the main activity class so here below this declaration of this button

30
00:01:39,970 --> 00:01:43,930
I can actually say private's.

31
00:01:44,060 --> 00:01:49,430
And by the way it's better to actually declare your value but as these user interface components are

32
00:01:49,820 --> 00:01:54,430
actually as private so that it is only private to the main activity class so private.

33
00:01:54,710 --> 00:01:59,670
And the name of this first you need to specify the data type of this value which is going to be streamed

34
00:02:00,730 --> 00:02:10,170
the name of this rally is going to be destination destination location address.

35
00:02:10,310 --> 00:02:15,920
And let's actually initially assigned an empty string value to this variable.

36
00:02:16,220 --> 00:02:17,600
So let's scroll down here.

37
00:02:17,780 --> 00:02:22,100
And here I can actually create an if statement in say this unclick in effect and after this line of

38
00:02:22,100 --> 00:02:25,160
code that actually creates this is geocoding value.

39
00:02:25,190 --> 00:02:31,650
I can actually say if address so address value I am referring to this added value.

40
00:02:31,740 --> 00:02:35,990
That's actually the way to say it is not equal to.

41
00:02:35,990 --> 00:02:39,800
So I need to pass I need to put this ban here.

42
00:02:39,800 --> 00:02:40,900
This is called bank right.

43
00:02:40,910 --> 00:02:41,690
Not not.

44
00:02:41,690 --> 00:02:49,810
Operator dot equals destination location address so why am I checking for this condition here.

45
00:02:49,820 --> 00:02:57,560
I am actually taking that if the old old adage that the user has entered is actually equal to the destination

46
00:02:57,560 --> 00:03:02,120
location address that is already actually entered.

47
00:03:02,120 --> 00:03:03,770
So let me ask you to show you the emulator.

48
00:03:03,770 --> 00:03:05,580
So here it is our emulator right.

49
00:03:05,870 --> 00:03:11,000
And if the is it actually enters an address here and if the user actually clicks on this get the data

50
00:03:11,000 --> 00:03:14,610
button the user is going to actually get some data.

51
00:03:14,690 --> 00:03:20,750
Ok for example the distance between the current location and the destination location and the actually

52
00:03:20,840 --> 00:03:23,760
remained time in order to get there.

53
00:03:23,840 --> 00:03:29,930
Actually the time left in order to get to that destination location if the user actually wants to click

54
00:03:29,990 --> 00:03:37,130
on this button again this statement is not going to be executed because the address value located the

55
00:03:37,130 --> 00:03:44,210
value that is inside of this text is actually completely the same as the value that is assigned to this

56
00:03:44,210 --> 00:03:45,950
destination location address.

57
00:03:45,950 --> 00:03:51,160
So we're going to actually assign a value to the initial location address inside the if statement.

58
00:03:51,200 --> 00:03:54,330
So that's what I am actually taking for this condition.

59
00:03:54,350 --> 00:04:00,320
I don't want this actually process to be executed actually two times.

60
00:04:00,350 --> 00:04:04,200
I just want the new address to be executed only once.

61
00:04:04,430 --> 00:04:08,480
And if the user gets the address gets these that actually gets the data.

62
00:04:08,750 --> 00:04:12,450
And that's going to be actually enough for that specific address.

63
00:04:12,710 --> 00:04:13,050
OK.

64
00:04:13,130 --> 00:04:18,620
So I don't want the address value to be equal to the destination location an address.

65
00:04:18,620 --> 00:04:23,440
So now not is that the address value is the value of this.

66
00:04:23,460 --> 00:04:24,580
It is the address.

67
00:04:24,740 --> 00:04:25,250
OK.

68
00:04:25,490 --> 00:04:27,640
So let's actually go inside the standard studio.

69
00:04:27,740 --> 00:04:31,820
Let's open and close this if statement by using this curly braces.

70
00:04:31,970 --> 00:04:34,400
So let's see what's what you're going to do here.

71
00:04:34,410 --> 00:04:36,120
Inside each statement.

72
00:04:36,200 --> 00:04:43,730
First of all are you going to actually sign that this nation location address to the address value right.

73
00:04:43,820 --> 00:04:49,550
Destination location address assignment operator at this value so you can see that we are assigning

74
00:04:49,550 --> 00:04:54,530
this destination location at least that is the value if it is not equal here.

75
00:04:54,700 --> 00:04:59,150
All the industry is going to execute the lines of code inside this if statement.

76
00:04:59,330 --> 00:04:59,680
Right.

77
00:04:59,720 --> 00:05:01,860
So this is the first thing that you want to do.

78
00:05:03,510 --> 00:05:11,070
And now you want to actually create an object of type geocoder in order to convert the latitude and

79
00:05:11,070 --> 00:05:18,330
longitude coordinates to a human readable address OK to a human readable actually de-value so that the

80
00:05:18,340 --> 00:05:19,970
user can see what's going on here.

81
00:05:19,970 --> 00:05:28,240
For example the amount of time the distance so I can actually say geocoder geocoder is a class inside

82
00:05:28,240 --> 00:05:28,370
that.

83
00:05:28,380 --> 00:05:33,690
And with that location package geocoder and the name is going to be geocoder the name of the variable

84
00:05:33,690 --> 00:05:35,530
assignment operator new.

85
00:05:35,830 --> 00:05:36,390
Right.

86
00:05:36,510 --> 00:05:39,050
Geocoder semicon.

87
00:05:39,060 --> 00:05:45,920
So here we actually created this object of type geocoder and we assigned to this object to this valuable

88
00:05:46,010 --> 00:05:46,800
type geocoder.

89
00:05:46,800 --> 00:05:50,420
So now this variable halts this object right.

90
00:05:50,490 --> 00:05:56,750
And as you can see inside Apprentice's of this constructed of these geocoder we must pass the context.

91
00:05:56,790 --> 00:05:59,990
The context is main activity that this.

92
00:06:00,000 --> 00:06:07,320
So instead of actually passing main activity that is we can't just say good application context right.

93
00:06:07,350 --> 00:06:12,590
It's also possible to pass good application context and it's going to automatically specify the context

94
00:06:12,600 --> 00:06:14,510
so the context is main activity right.

95
00:06:14,580 --> 00:06:24,180
So that's it and now because the process of geocoding are actually our latitude and longitude coordinates

96
00:06:24,180 --> 00:06:25,800
can actually fail.

97
00:06:25,980 --> 00:06:27,580
We need to put our codes.

98
00:06:27,600 --> 00:06:33,050
We need to put the process of Dakotan inside a try catch block so that they can actually catch the exception.

99
00:06:33,090 --> 00:06:39,890
Otherwise our application is it may actually crash and we may have not be able to do anything.

100
00:06:40,050 --> 00:06:46,690
So let's actually create a try catch plug so try create a try and then here at the after the curly brace

101
00:06:46,690 --> 00:06:47,390
of this Troy.

102
00:06:47,460 --> 00:06:51,790
Just leave it here catch inside the practice of this catch just tape in here.

103
00:06:51,810 --> 00:06:58,240
Acception exception and the name is E and open and close.

104
00:06:58,240 --> 00:07:01,980
This catch like by using these curly braces I just they've been here.

105
00:07:02,300 --> 00:07:08,140
That print stack trace it can actually display somebody who's going out with somebody to the like so

106
00:07:08,140 --> 00:07:10,300
that you can actually see what's been thrown.

107
00:07:10,450 --> 00:07:12,290
So let's go inside the triple judge.

108
00:07:12,490 --> 00:07:19,080
So let's create a list list and let's actually put a pair of angle brackets at inside angle brackets.

109
00:07:19,120 --> 00:07:24,610
You want to specify the values that you want to put and should able to specify the data type of the

110
00:07:24,610 --> 00:07:26,610
values that you want to put inside the list.

111
00:07:26,620 --> 00:07:32,310
So now you may ask what is that list list is like an army list is not a class.

112
00:07:32,320 --> 00:07:36,890
It is actually an interface and it is actually like an ad a but with more features.

113
00:07:36,970 --> 00:07:39,670
OK we can do lots of things with lists.

114
00:07:39,850 --> 00:07:41,780
So just look at this list as an adult.

115
00:07:41,830 --> 00:07:42,280
OK.

116
00:07:42,460 --> 00:07:48,520
So list and just put angle brackets inside the angle brackets unless specified that date or type of

117
00:07:48,700 --> 00:07:52,990
the values that are you want to put inside this list which is going to be a fake address.

118
00:07:52,990 --> 00:07:56,710
Look at this here address is inside and read that location package.

119
00:07:56,710 --> 00:08:00,940
So just put it here address and the name of this list is going to be.

120
00:08:01,000 --> 00:08:06,850
For example my addresses my addresses assignment operator.

121
00:08:07,240 --> 00:08:14,590
So notice that because this is actually the list and this is an interface which can not create actually

122
00:08:14,800 --> 00:08:17,650
an instance of type least by using the new keyboard.

123
00:08:17,650 --> 00:08:21,100
It is not possible because this is actually an interface.

124
00:08:21,190 --> 00:08:23,740
So let's see how we can initialize this interface.

125
00:08:23,860 --> 00:08:29,440
So now it's time to actually forward to our geocoder object dots.

126
00:08:29,620 --> 00:08:35,380
Let's actually for this method get from location name you can this you can see this one here and it's

127
00:08:35,380 --> 00:08:40,480
actually set like this one and then person until January worth as you can see there are two versions

128
00:08:40,480 --> 00:08:42,090
of this method here.

129
00:08:42,310 --> 00:08:49,020
The first version that may actually show you again the first version actually accepts two arguments.

130
00:08:49,020 --> 00:08:50,720
Actually the location name.

131
00:08:50,730 --> 00:08:52,410
So it is going to be the address.

132
00:08:52,460 --> 00:08:53,230
Right.

133
00:08:53,250 --> 00:08:59,340
The user enters the address inside as it takes the first actually the EDT address name right.

134
00:08:59,340 --> 00:09:03,490
It is the address the user enters the address inside that field.

135
00:09:03,690 --> 00:09:06,080
And the second argument is the max results.

136
00:09:06,120 --> 00:09:12,000
So it's going to actually turn that some Max resolve some results actually from the address for example

137
00:09:12,180 --> 00:09:15,200
it's going to actually say you are here you are actually to somebody else.

138
00:09:15,210 --> 00:09:20,800
So it's going to give you the most accurate addresses and the want five addresses.

139
00:09:20,910 --> 00:09:27,550
For example 10 addresses or 20 addresses you can specify that here by using this Max results actually

140
00:09:27,720 --> 00:09:28,730
argument.

141
00:09:28,800 --> 00:09:30,980
Look at this second version of this.

142
00:09:31,070 --> 00:09:34,700
If you have the option to actually pass the address name.

143
00:09:34,800 --> 00:09:37,420
You have the option to pass the max odds.

144
00:09:37,590 --> 00:09:42,870
You have the option to actually pass the lower left latitude you have the option to pass the lower left

145
00:09:42,870 --> 00:09:47,700
longitude of the upper right latitude and longitude.

146
00:09:47,700 --> 00:09:52,170
So for this application we just want to use the first version of this method is actually really good

147
00:09:52,200 --> 00:09:53,140
and it's enough.

148
00:09:53,310 --> 00:09:56,300
OK we don't have to actually pass the latitude longitude.

149
00:09:56,370 --> 00:10:00,660
We just want to give our application the address and the address and the application is going to just

150
00:10:00,660 --> 00:10:01,310
give us OK.

151
00:10:01,360 --> 00:10:06,210
So you are here is going to actually determine your current location and it's going to tell you that

152
00:10:06,570 --> 00:10:11,720
the destination address is there and then it's going to give you the distance the meters to get there

153
00:10:11,970 --> 00:10:15,470
and it's going to give you the time that it is going to take to get there.

154
00:10:15,480 --> 00:10:22,500
So now inside Apprentice's I can actually specify the location in which she is going to be destination

155
00:10:22,530 --> 00:10:23,830
location address.

156
00:10:24,010 --> 00:10:24,610
Right.

157
00:10:24,680 --> 00:10:26,690
Come on at the max results.

158
00:10:26,680 --> 00:10:34,020
I've been to actually only get four addresses so in this way we are initializing our list right.

159
00:10:34,020 --> 00:10:38,600
Our list is going to have four accurate addresses the most.

160
00:10:38,610 --> 00:10:45,240
Actually actually the most accurate addresses that are going to be only four and we can see that by

161
00:10:45,240 --> 00:10:48,960
using by passing this address is going to give us those results.

162
00:10:48,960 --> 00:10:49,970
So this is our list.

163
00:10:49,980 --> 00:10:54,280
My address is Lydney actually create a new line here so that you can see what's going on here.

164
00:10:54,300 --> 00:11:03,860
Now let me create an if statement so if my addresses actually is not equal to non If this list actually

165
00:11:03,860 --> 00:11:07,630
has some addresses and it is not equal to null.

166
00:11:07,910 --> 00:11:12,980
Then we can actually go inside the if statement and we can't say so remember that I told you that the

167
00:11:12,980 --> 00:11:19,340
geocoder is going to actually convert that latitude and longitude coordinates to actually a human readable

168
00:11:19,340 --> 00:11:21,980
text so that they can actually see what's going on here.

169
00:11:22,310 --> 00:11:28,550
And now I want to actually pass the latitude and longitude but first I need to get the latitude and

170
00:11:28,550 --> 00:11:30,070
longitude how we can do that.

171
00:11:30,140 --> 00:11:36,620
Let's actually create a value of the double and the name is going to be latitude latitude assignment

172
00:11:36,620 --> 00:11:37,470
operator.

173
00:11:37,610 --> 00:11:42,070
And here I can refer to this least my addresses.

174
00:11:42,450 --> 00:11:44,590
OK that's good.

175
00:11:44,690 --> 00:11:46,120
So I want to get the value.

176
00:11:46,180 --> 00:11:51,170
The first address actually that is inside the index 0 0 0.

177
00:11:51,260 --> 00:11:59,370
Notice that we get four addresses so I want to get the address that is inside the index 0 dots get latitude.

178
00:11:59,420 --> 00:12:05,300
I am actually calling this get latitude on the address inside the index zero of this my address list.

179
00:12:05,330 --> 00:12:07,390
So in this way we get this latitude.

180
00:12:07,700 --> 00:12:16,620
Let's actually create another variable of that double longitudes assignment operator my addresses that

181
00:12:16,980 --> 00:12:22,690
get zero dot get longitude right.

182
00:12:22,730 --> 00:12:24,560
Semicolon.

183
00:12:24,650 --> 00:12:29,370
Now let's actually create a variable of type location here.

184
00:12:29,570 --> 00:12:33,750
I'm going to actually let you know what am I creating this location variable but for now I just create

185
00:12:33,750 --> 00:12:34,460
this value.

186
00:12:34,650 --> 00:12:36,200
And then I'll tell you what's going on here.

187
00:12:36,240 --> 00:12:37,340
Exactly.

188
00:12:37,390 --> 00:12:44,990
So location and the name of this value and it's going to be address location address location address

189
00:12:46,120 --> 00:12:56,410
assignment operator new location new location and you need to pass an argument to this actually constructed

190
00:12:56,440 --> 00:12:58,230
of this location class.

191
00:12:58,240 --> 00:13:02,130
So let's actually just going to be off base 3 and so just pass the value.

192
00:13:02,170 --> 00:13:08,750
So let me show you what is the data type so location and you can see that it says street provider.

193
00:13:08,750 --> 00:13:12,930
So we need to provide and should if you need to specify a provider which is of type string.

194
00:13:13,120 --> 00:13:19,720
So I'll tell you it's not that important but it is called a provider is so that we can actually use

195
00:13:19,720 --> 00:13:20,070
it later.

196
00:13:20,080 --> 00:13:24,250
But for now in this application we are not going to use it so just pass the procedure here because of

197
00:13:24,250 --> 00:13:24,880
the history.

198
00:13:24,910 --> 00:13:26,650
I can't say my destination.

199
00:13:26,880 --> 00:13:27,300
OK.

200
00:13:27,400 --> 00:13:36,010
It doesn't really matter which value it is just past Ossining value my destination semicolon right now

201
00:13:36,800 --> 00:13:42,210
that I have this location variable here which its name is location address.

202
00:13:42,490 --> 00:13:51,570
I can say location address that set latitude and I have this latitude here right that I get from this

203
00:13:51,750 --> 00:14:02,410
of this list so I can pass the latitude here latitude location address that set longitude and I can

204
00:14:02,410 --> 00:14:04,010
pass the longitude here.

205
00:14:05,120 --> 00:14:06,000
Right.

206
00:14:06,140 --> 00:14:12,350
So I created a variable of type location here and I passed the profiler here and I said that the latitude

207
00:14:12,350 --> 00:14:13,160
is this one.

208
00:14:13,270 --> 00:14:13,730
OK.

209
00:14:13,820 --> 00:14:17,740
And I said that the longitude is this one so I get the latitude and longitude from this my addresses

210
00:14:17,770 --> 00:14:24,470
are from the first index the value that is under its index of this list and a past the latitude and

211
00:14:24,530 --> 00:14:30,980
longitude of that address to the actually latitude and longitude property or instance variable of this

212
00:14:31,100 --> 00:14:31,670
location.

213
00:14:31,670 --> 00:14:33,700
Address right is valuable.

214
00:14:33,920 --> 00:14:36,350
So now what am I going to do here.

215
00:14:36,520 --> 00:14:37,530
I actually created.

216
00:14:37,550 --> 00:14:43,880
This right here BELOFF take location because we have another class in our project called Paxi manager

217
00:14:44,390 --> 00:14:46,480
the taxi manager class is our model.

218
00:14:46,630 --> 00:14:50,550
What is the model the model is going to actually provide that data for us.

219
00:14:50,570 --> 00:14:50,970
OK.

220
00:14:51,080 --> 00:14:56,130
We cannot actually continue using the application without the model the model is the data source.

221
00:14:56,210 --> 00:14:59,950
Without the data source the application doesn't have a data source and it is boring.

222
00:15:00,110 --> 00:15:00,520
Right.

223
00:15:00,680 --> 00:15:03,110
So let's actually scroll to the top.

224
00:15:03,410 --> 00:15:07,370
Let's create a value of piked amount of type Paxi manager.

225
00:15:07,370 --> 00:15:14,480
So now here after this line of code here in line number actually 41 inside the main activity class I

226
00:15:14,480 --> 00:15:20,960
can actually say private taxi manager private taxi manager and the name of this rally is going to be

227
00:15:20,960 --> 00:15:27,170
taxi manager Senechal all right let's go inside is uncreate Lifford here unless actually initialize

228
00:15:27,170 --> 00:15:27,980
the taxi manager.

229
00:15:28,000 --> 00:15:33,080
After this line of code that actually sets the listener on the spot it is Uncle close.

230
00:15:33,170 --> 00:15:41,010
So I can't say taxi manager I can leave it to this variable taxi manager new taxi manager semi-colon.

231
00:15:41,240 --> 00:15:48,290
So now I created a variable Actually I created the of the taxi manager here and I assigned this object

232
00:15:48,350 --> 00:15:51,260
of Tove taxi manager to this valuable light.

233
00:15:51,260 --> 00:15:56,190
So now this taxi managed valuable holds this object of a Pepsi manager.

234
00:15:56,390 --> 00:15:57,990
So hopefully that makes sense.

235
00:15:58,190 --> 00:16:00,660
Now let's scroll down here.

236
00:16:01,040 --> 00:16:07,120
And here in this statement that I am actually taking for it not lability of this my address is here

237
00:16:07,970 --> 00:16:13,850
after this line of code that actually sets the longitude of this location at least I can say taxi manager

238
00:16:13,880 --> 00:16:20,570
I can refer to this rowdier but that holds the object of the taxing manager right that sets destination

239
00:16:20,570 --> 00:16:22,910
location location.

240
00:16:22,910 --> 00:16:25,730
Address right.

241
00:16:25,740 --> 00:16:27,370
So what did I do here.

242
00:16:27,600 --> 00:16:33,870
I actually passed the location address as an argument to this method that I created inside the taxi

243
00:16:33,870 --> 00:16:34,500
manager class.

244
00:16:34,500 --> 00:16:35,950
This is actually an instance method.

245
00:16:35,950 --> 00:16:41,940
So it is going to be called on an instance of type actually Paxi manager class.

246
00:16:41,940 --> 00:16:47,420
So taxi manager is an instance of the taxi manager class that sets destination location is going to

247
00:16:47,420 --> 00:16:49,740
actually set the destination location.

248
00:16:49,740 --> 00:16:53,540
So we passed this location address as an argument to this effect.

249
00:16:53,670 --> 00:16:57,040
So it's going to assign this location address to the.

250
00:16:57,210 --> 00:17:00,690
Actually this initial location instance variable of the taxi manager class.

251
00:17:00,700 --> 00:17:05,830
So let's go to the taxi manager class here let me show you this your destination location right.

252
00:17:05,880 --> 00:17:07,060
This is an instance variable.

253
00:17:07,080 --> 00:17:09,430
And if you have the Smurfette here we created ourselves.

254
00:17:09,500 --> 00:17:11,250
This thing is set this initial location.

255
00:17:11,280 --> 00:17:16,260
So here this if it accepts an argument of a location so it's going to actually assign that argument

256
00:17:16,680 --> 00:17:19,340
to the destination location instance valuable.

257
00:17:19,350 --> 00:17:21,470
So let's go to the let's go back to the man with the class.

258
00:17:21,480 --> 00:17:25,180
So that's what we are doing here we are passing the location address as an argument to these men.

259
00:17:25,350 --> 00:17:31,750
And it's going to assign this location address to the destination location instance variable of this

260
00:17:31,770 --> 00:17:33,320
taxi manager.

261
00:17:33,330 --> 00:17:35,130
That's right.

262
00:17:35,190 --> 00:17:36,330
So that's it.

263
00:17:36,360 --> 00:17:39,810
Now let's see how we can use this object this model.

264
00:17:39,960 --> 00:17:40,660
Right.

265
00:17:40,800 --> 00:17:44,020
So now let's scroll down here.

266
00:17:44,280 --> 00:17:50,760
And after the end in curly brace of this statement here right this statement that we created here inside

267
00:17:50,770 --> 00:17:57,600
is unclear if it goes to him for actually not being equal of this address value and this distillation

268
00:17:57,720 --> 00:18:01,100
destination location address is valuable here.

269
00:18:01,110 --> 00:18:08,300
After the end in curly brace of this statement now I want to create another Actually I want to actually

270
00:18:08,330 --> 00:18:09,320
put some logic here.

271
00:18:09,320 --> 00:18:14,580
I want to add some lines of code here inside this on collegium efforts so before the end incredible

272
00:18:14,590 --> 00:18:19,090
case of the Smurfette Let's actually see what what we are going to do here.

273
00:18:20,440 --> 00:18:25,090
So because so you are already familiar with this because you want to actually access the user's current

274
00:18:25,090 --> 00:18:25,920
location.

275
00:18:26,110 --> 00:18:30,820
We must ask the user for the permission in order to access the user's location.

276
00:18:30,820 --> 00:18:36,070
So let's create a valuable for that end and the name of this rally but it's going to be permission check

277
00:18:36,640 --> 00:18:45,970
permission check assignment operator and I can't say context compact context compact that check self

278
00:18:45,970 --> 00:18:47,140
permission.

279
00:18:47,140 --> 00:18:52,280
So for the first argument we need to pass the context so I can just say good application context.

280
00:18:52,310 --> 00:18:53,460
Come on.

281
00:18:53,860 --> 00:18:57,070
And as the second argument we need to specify the permission.

282
00:18:57,220 --> 00:19:00,050
So I can't say manifest that permission.

283
00:19:00,920 --> 00:19:04,760
That course location access course location.

284
00:19:04,760 --> 00:19:10,810
So let me actually create a new line here so that you can actually see the entire effort here.

285
00:19:11,180 --> 00:19:15,550
So now that we have the permission check let's create and if statements.

286
00:19:15,860 --> 00:19:19,340
OK first let's actually put a semicolon here at the end of our statement.

287
00:19:19,460 --> 00:19:27,830
And now let's create an if statement so if permission check is equal to package manager that permission

288
00:19:27,830 --> 00:19:32,990
granted the Capitol right that permission granted or just need to open and close.

289
00:19:32,990 --> 00:19:37,460
This move this statement by using the school libraries so you can see that if the permission check is

290
00:19:37,460 --> 00:19:43,880
equal to a package manager that permission granted means that we have the permission to access the user's

291
00:19:43,880 --> 00:19:44,600
location.

292
00:19:44,780 --> 00:19:45,230
OK.

293
00:19:45,440 --> 00:19:51,350
So let's create an exit statements or else it just means that we don't have to actually get permission

294
00:19:51,350 --> 00:19:52,730
to access the user's location.

295
00:19:52,730 --> 00:19:58,460
So let's request that let's ask the user to give us the permission to to access the location.

296
00:19:58,460 --> 00:20:00,200
So let me paste this line of code here.

297
00:20:00,230 --> 00:20:05,600
As you can see I paste this I pasted this line of work here that says activity can pass that request

298
00:20:05,600 --> 00:20:06,380
permissions.

299
00:20:06,470 --> 00:20:11,340
First we need to pass the context main activity that this and as the second argument we need to specify

300
00:20:11,350 --> 00:20:13,350
to actually the permission as an addict.

301
00:20:13,460 --> 00:20:15,360
So new streams A.

302
00:20:15,520 --> 00:20:21,680
And I just passed the first actually the first value this is going to have only one value which is going

303
00:20:21,680 --> 00:20:26,920
to be accessed course location and at a permissions right because you want to have only one actually

304
00:20:26,970 --> 00:20:31,640
permission in this application you won't be able to actually access one.

305
00:20:31,680 --> 00:20:33,890
A dangerous mission for example.

306
00:20:33,890 --> 00:20:39,230
So I just passed this value here to manifest that permission that the access course location.

307
00:20:39,470 --> 00:20:41,340
And here it is actually that request code.

308
00:20:41,480 --> 00:20:43,360
So it is ok to be number one.

309
00:20:43,610 --> 00:20:44,300
Right.

310
00:20:44,650 --> 00:20:50,650
And now that we have actually requested the user to give us the permission here before this one image

311
00:20:50,660 --> 00:20:56,990
that I can actually say for example takes the distance that it takes two coats.

312
00:20:57,020 --> 00:21:04,380
And here I can say this up is not allowed is not allowed.

313
00:21:05,190 --> 00:21:15,800
To access the location right now let's actually go inside this if statement so what happens if the user

314
00:21:15,850 --> 00:21:18,820
actually allows us to access the location.

315
00:21:18,820 --> 00:21:22,300
So now we want to put that logic here inside this statement.

316
00:21:22,330 --> 00:21:27,910
So for that we need to put we need to actually to use the main entry entry point in order to access

317
00:21:27,910 --> 00:21:32,650
that user's location which is actually called fuse location provider API.

318
00:21:32,650 --> 00:21:40,220
This fuse location provider API is actually the main entry point in order to access the user's location.

319
00:21:40,330 --> 00:21:54,150
So let's actually name it the same fuse actually fuse location provider API write assignment operator

320
00:21:54,610 --> 00:22:04,200
and and here I can actually say location services that used location services that fuse location API

321
00:22:04,810 --> 00:22:06,110
right semicolon.

322
00:22:06,240 --> 00:22:08,370
So it may actually create a new line here.

323
00:22:09,740 --> 00:22:11,450
So that they can see what's going on here first.

324
00:22:11,570 --> 00:22:20,210
We created a bit of type fuse location approach by the API here and we assigned this value to this valuable

325
00:22:20,600 --> 00:22:22,730
location services that fuse location API.

326
00:22:22,730 --> 00:22:24,950
So now we have that main entry point.

327
00:22:25,130 --> 00:22:30,380
So now I can say so now we can actually access the user's location.

328
00:22:30,380 --> 00:22:31,070
So lets do that.

329
00:22:31,070 --> 00:22:37,280
So it lets you to create a variable of the location and the name of this value is going to be user current

330
00:22:38,120 --> 00:22:41,790
location assignment operator.

331
00:22:42,100 --> 00:22:48,800
And here you can see fuse location pro-white API that gets last location.

332
00:22:49,090 --> 00:22:49,900
OK good.

333
00:22:49,950 --> 00:22:55,610
Lastly location and we need to pass the Google API client to the Smurfette So we have an instance of

334
00:22:55,610 --> 00:22:57,660
that Google client here semicolon.

335
00:22:57,800 --> 00:22:58,600
So thats it.

336
00:22:58,850 --> 00:23:05,930
And this way we can actually access the users actually last location and we can assign it to this valuable

337
00:23:05,930 --> 00:23:07,960
user current location.

338
00:23:07,970 --> 00:23:12,350
So now you want to actually create an if statement and I want to let you know about it.

339
00:23:12,380 --> 00:23:16,610
A very important point about geocoding in Android.

340
00:23:16,610 --> 00:23:23,120
So after this line of code that actually gets the use that was current location I can say if user current

341
00:23:23,120 --> 00:23:28,100
location is not equal to null OK.

342
00:23:28,610 --> 00:23:32,050
And this is actually an ontological OPERATOR Right.

343
00:23:32,270 --> 00:23:38,250
Is geocoding So here this is very important let's actually be open and close this if statement by using

344
00:23:38,250 --> 00:23:41,650
these curly braces and often incredibly is followed by a closing curly brace.

345
00:23:41,670 --> 00:23:48,150
So here I am actually thinking that if this use of current location is not equal to not and is geocoding

346
00:23:48,420 --> 00:23:55,410
is geocoding here means that if the value of this is geocoding variable is true and the user is actually

347
00:23:55,420 --> 00:23:56,170
to caught in it.

348
00:23:56,190 --> 00:23:56,680
Right.

349
00:23:56,910 --> 00:23:58,920
So there is a problem here.

350
00:23:59,010 --> 00:24:03,450
Let's actually scroll to the top here and see that we have this try catch block right.

351
00:24:03,480 --> 00:24:08,870
So here we are actually change for the condition for the process of coding.

352
00:24:08,880 --> 00:24:12,980
So what happens if geocoding actually goes wrong.

353
00:24:13,050 --> 00:24:19,640
OK if the user can actually cannot for example the location of the user cannot be of the address of

354
00:24:19,740 --> 00:24:22,080
for example the address that that the user has entered.

355
00:24:22,110 --> 00:24:26,420
For example in that case that address cannot be for example found right.

356
00:24:26,490 --> 00:24:28,590
The geocoding could go wrong.

357
00:24:29,020 --> 00:24:31,890
So we need to go inside is Cheche plug.

358
00:24:32,070 --> 00:24:37,890
And we need to say is geocoding false right semicolon.

359
00:24:38,090 --> 00:24:39,460
So inside it is catchable.

360
00:24:39,590 --> 00:24:46,950
We must assign the value falls to this is Joe geocoding so that the application is not going to code.

361
00:24:47,060 --> 00:24:52,970
If the geocoding is actually going wrong so that it's not going actually it's the device's battery it

362
00:24:52,970 --> 00:24:57,520
is very important because it is very it is a very hard working process.

363
00:24:57,530 --> 00:25:00,100
It's going to be used as a battery.

364
00:25:00,110 --> 00:25:02,990
It is going to it the device is battery.

365
00:25:02,990 --> 00:25:07,430
So here you can see that initially the assigned value truth is valuable.

366
00:25:07,430 --> 00:25:11,930
So whenever they use it actually clicks on that button whenever they use that actually touches that

367
00:25:11,930 --> 00:25:12,380
button.

368
00:25:12,380 --> 00:25:14,770
Get the date of this if it is going to be caught.

369
00:25:14,780 --> 00:25:19,000
So this means that the value true is going to be assigned to this is Joe geocoding.

370
00:25:19,190 --> 00:25:24,950
But if the geocoding goes wrong it can actually execute this catch block and it's going to assign the

371
00:25:24,950 --> 00:25:30,650
value falls to these is geocoding valuable so that it's not going to actually court anymore.

372
00:25:30,820 --> 00:25:31,440
OK.

373
00:25:31,500 --> 00:25:35,060
And as a result it's not going to actually eat the use that as battery.

374
00:25:35,060 --> 00:25:41,490
So now let's actually scroll down here and here is for this statement We are thinking that if that is

375
00:25:41,540 --> 00:25:46,320
current location is not equal to an ad is geocoding is actually true.

376
00:25:46,340 --> 00:25:49,490
So this means that it didn't actually run.

377
00:25:49,580 --> 00:25:51,870
So it actually works perfectly here.

378
00:25:51,890 --> 00:26:00,360
Now I can't say inside this statement takes the distance that said text that said text.

379
00:26:00,590 --> 00:26:02,660
And now I can actually access the model.

380
00:26:02,700 --> 00:26:07,640
OK the model object that we created Paxi manager thought.

381
00:26:08,100 --> 00:26:10,700
And you can see that we have these two methods right.

382
00:26:10,830 --> 00:26:16,210
This one return the miles between the current location and the destination location here.

383
00:26:16,440 --> 00:26:20,130
And you can see that this Smurfette accepts two arguments.

384
00:26:20,130 --> 00:26:22,350
The first one is the current location of the user.

385
00:26:22,350 --> 00:26:28,050
So we have that to use a current location right so I can just pass that value here use their current

386
00:26:28,050 --> 00:26:29,720
location karma.

387
00:26:30,030 --> 00:26:34,170
And now we need to pass the meters per mile.

388
00:26:34,380 --> 00:26:34,890
OK.

389
00:26:35,070 --> 00:26:38,680
So the meters per mile is a value that we are going to get from our.

390
00:26:38,730 --> 00:26:39,270
Eddie takes.

391
00:26:39,270 --> 00:26:41,490
Let me show you the emulator.

392
00:26:41,490 --> 00:26:46,020
So this is our emulator and this is actually the term meters per mile.

393
00:26:46,050 --> 00:26:46,680
Right.

394
00:26:46,680 --> 00:26:52,350
So whether the user actually enters our value here that value is going to be passed as this argument

395
00:26:52,380 --> 00:26:54,450
as the second argument meters per mile.

396
00:26:54,630 --> 00:26:55,970
It is going to be off the.

397
00:26:56,100 --> 00:27:00,270
But the value that the user actually enters inside is as it takes is going to be off the street.

398
00:27:00,360 --> 00:27:04,380
So we need to actually convert that string value to an integer value.

399
00:27:04,380 --> 00:27:05,730
Lets see how we can do that.

400
00:27:05,760 --> 00:27:12,960
I can actually use the class Integer as you can see the or it is capitalized the right integer to parse.

401
00:27:13,290 --> 00:27:16,450
So this is actually the static method of this integer integer class.

402
00:27:16,520 --> 00:27:16,850
Right.

403
00:27:16,950 --> 00:27:22,250
And instead Apprentice's of this parse into method I need to pass a value of type streambed.

404
00:27:22,320 --> 00:27:25,220
So it is going to be converted to a value of integer.

405
00:27:25,380 --> 00:27:36,350
So I can just say EDT actually meters per mile Dud's get text that it takes that to string.

406
00:27:36,690 --> 00:27:42,620
So it is actually a very long method but as you can see I have that extra Apprentice's here.

407
00:27:42,630 --> 00:27:44,390
So now it is actually correct.

408
00:27:44,430 --> 00:27:50,880
So it is actually a lot to learn but it is very simple it may actually create a new line here.

409
00:27:50,910 --> 00:27:55,740
So as you can see we have actually this taxi manager and we are calling this movement and its taxi manager

410
00:27:55,770 --> 00:28:00,350
object returned the miles between the current location and its destination location.

411
00:28:00,360 --> 00:28:04,920
So we passed that they use that kind of location as the first argument.

412
00:28:04,950 --> 00:28:08,320
The second argument is going to be to actually the meters per mile.

413
00:28:08,460 --> 00:28:14,250
So because the user is supposed to enter that value inside it it takes that value is going to be off

414
00:28:14,250 --> 00:28:15,060
the street.

415
00:28:15,180 --> 00:28:20,080
So Vinita actually converts that value to our and to an integer value.

416
00:28:20,190 --> 00:28:20,690
Right.

417
00:28:20,730 --> 00:28:26,450
So let me tell you that they use it when the actually the user enters a value inside these editrix.

418
00:28:26,550 --> 00:28:30,720
It is not actually necessarily of types 3 and it is often editable.

419
00:28:30,920 --> 00:28:31,350
OK.

420
00:28:31,590 --> 00:28:34,890
So if you want to you need to actually convert it to a string value.

421
00:28:34,890 --> 00:28:36,770
So thats what we are doing here.

422
00:28:36,840 --> 00:28:41,650
We are getting the value of this EDT meter's pyramid that it takes two to three.

423
00:28:41,910 --> 00:28:47,880
And if you are using this method parse it on the integer class in order to convert a string about you

424
00:28:47,880 --> 00:28:49,690
to an integer value here.

425
00:28:49,770 --> 00:28:50,400
Right.

426
00:28:50,460 --> 00:28:54,880
And here there is a problem and the problem is that the problem is actually solved.

427
00:28:54,930 --> 00:29:01,680
Its not a very big deal but the problem is that we are assuming that the user actually enters a value

428
00:29:01,680 --> 00:29:06,930
of type integer here so that it is actually convertible to an integer value if they use it.

429
00:29:06,930 --> 00:29:12,440
For example Intel is of value for example of types 3 and our application is going to crash in the neck

430
00:29:12,480 --> 00:29:19,350
in their previous tutorials of this course I taught you how we can actually use the try catch the exception

431
00:29:19,350 --> 00:29:25,910
handling techniques in Java in order to prevent those kinds of crashes in your application.

432
00:29:26,020 --> 00:29:30,930
OK so I'm not going to cover that here too because you already know about that you already know how

433
00:29:30,930 --> 00:29:32,560
to use the try catch here.

434
00:29:32,610 --> 00:29:38,880
You can't just put it create a try catch and inside the tribal touch you can actually use this piece

435
00:29:38,880 --> 00:29:44,970
of code and you can convert this string value to an integer value and instead the catch block you can

436
00:29:44,970 --> 00:29:49,380
actually just catch the exception and your application is not going to crash.

437
00:29:49,500 --> 00:29:49,970
OK.

438
00:29:50,310 --> 00:29:53,830
So that's it you are converting the string value to an integer value.

439
00:29:54,030 --> 00:29:57,560
And now this actually puts the second piece of code here.

440
00:29:57,840 --> 00:30:03,780
So after we actually setting some text to this text the distance I need to just type in here takes the

441
00:30:03,780 --> 00:30:04,490
time.

442
00:30:04,800 --> 00:30:08,410
OK that set text.

443
00:30:08,620 --> 00:30:16,750
And now again I can't say Paxi manager that returned that time left to get to destination location.

444
00:30:16,750 --> 00:30:20,490
So this faith accepts actually three arguments.

445
00:30:20,530 --> 00:30:25,270
The first one is they use their current location so I can pass that here use current location comma.

446
00:30:25,580 --> 00:30:30,090
OK so now in order to show you the arguments that me actually call it again.

447
00:30:30,320 --> 00:30:32,470
So I go in.

448
00:30:32,620 --> 00:30:34,140
So now you can see these arguments here.

449
00:30:34,140 --> 00:30:37,800
The first one is the use of current location comma.

450
00:30:37,840 --> 00:30:42,140
The second argument is the miles per hour or three miles per hour.

451
00:30:42,160 --> 00:30:44,200
So we have an eddy takes for that.

452
00:30:44,200 --> 00:30:45,760
Let me show you the emulator.

453
00:30:45,790 --> 00:30:50,080
This is actually this second Ed. This is actually that is 1 mph.

454
00:30:50,080 --> 00:30:53,680
So again we need to actually have a value of type.

455
00:30:53,710 --> 00:31:00,200
What we need to have a value of float and the value that actually the user enters inside is editrix.

456
00:31:00,280 --> 00:31:02,340
It is of tide actually stream.

457
00:31:02,350 --> 00:31:09,060
So we need to actually convert that value to our two and two offloads value so we can actually use them

458
00:31:09,160 --> 00:31:15,020
in the float class here and the Fed argument is actually that meters per mile.

459
00:31:15,040 --> 00:31:18,460
So let's actually specify the second premise here float.

460
00:31:18,670 --> 00:31:21,610
Let's use the float class you can see that the F is capitalized.

461
00:31:21,610 --> 00:31:27,330
Right thought Parsa float and I can pass a value of type string to this method.

462
00:31:27,370 --> 00:31:29,220
So the value is EDT.

463
00:31:29,610 --> 00:31:37,710
Actually miles per hour that get fixed that two is three right.

464
00:31:37,720 --> 00:31:40,190
So this is our second argument here.

465
00:31:40,450 --> 00:31:42,140
Let's actually put a comma here.

466
00:31:43,310 --> 00:31:46,910
And are actually our first argument is going to be bought.

467
00:31:46,910 --> 00:31:48,650
Let's actually put the comma here.

468
00:31:48,650 --> 00:31:49,140
OK.

469
00:31:49,250 --> 00:31:54,180
So because this second argument is he had floated parts float at the end in private practice this year

470
00:31:54,200 --> 00:31:58,990
is actually related related to this starting Prentice's of these parts float here.

471
00:31:59,000 --> 00:31:59,570
Right.

472
00:31:59,570 --> 00:32:01,020
So now let's specify this.

473
00:32:01,030 --> 00:32:07,230
The first argument actually the argument is the meters per mile that is going to be off that integers

474
00:32:07,230 --> 00:32:11,770
so I can see integer class that parse.

475
00:32:12,200 --> 00:32:19,510
And inside the apprentice's I can just say EDT to the EDT meters per mile.

476
00:32:19,930 --> 00:32:20,850
That's good.

477
00:32:20,860 --> 00:32:24,450
Text that to a string.

478
00:32:24,720 --> 00:32:25,060
Right.

479
00:32:25,110 --> 00:32:28,230
And finally I just need to put a semicolon at the end of my statement.

480
00:32:28,710 --> 00:32:30,750
And here there is actually an error.

481
00:32:30,750 --> 00:32:37,980
So let's let's create a new line here so that we can actually see what's going on here A.J. the person

482
00:32:38,000 --> 00:32:42,200
in it is meter per mile that takes that restraint.

483
00:32:42,300 --> 00:32:43,670
So we need to pass another.

484
00:32:43,730 --> 00:32:44,950
And in practice this year.

485
00:32:45,000 --> 00:32:48,000
So actually the last Prentice's was missed.

486
00:32:48,000 --> 00:32:51,970
So now it is here and everything is working fine.

487
00:32:51,970 --> 00:32:57,890
Here let me actually create another new line here so that you can actually see what's going on here.

488
00:32:57,900 --> 00:33:00,060
It is actually a very long method.

489
00:33:00,060 --> 00:33:01,240
So let me explain again.

490
00:33:01,260 --> 00:33:06,600
We have this taxi manager object we are calling this Smith had returned the time left to get to the

491
00:33:06,600 --> 00:33:13,240
destination location so it can actually give us the time actually lift to get to the destination location.

492
00:33:13,280 --> 00:33:15,390
This it accepts the argument arguments.

493
00:33:15,540 --> 00:33:18,020
The first argument is they use a complication.

494
00:33:18,090 --> 00:33:24,470
The second argument is actually the miles per hour that the user is supposed to provide for our application

495
00:33:24,480 --> 00:33:30,360
in order to actually calculate the time that is left in order to get to their destination location.

496
00:33:30,510 --> 00:33:35,030
And the first trimester actually the argument is metered as per mile.

497
00:33:35,250 --> 00:33:38,460
So it is actually here in Mr. paramount.

498
00:33:38,910 --> 00:33:42,840
And we are actually converting these values to their specific data.

499
00:33:42,840 --> 00:33:46,730
So for example this one is an integer value so if you call it is a class the.

500
00:33:46,890 --> 00:33:48,310
And this one is a float value.

501
00:33:48,390 --> 00:33:50,920
So we called float that float.

502
00:33:51,390 --> 00:33:52,210
So that's it.

503
00:33:52,500 --> 00:33:54,110
And everything is fine.

504
00:33:54,270 --> 00:34:00,730
Let's launch the application on the emulator here because I want to show you something very important.

505
00:34:00,870 --> 00:34:05,460
So now we can see that our application is actually running on the simulator and it says for example

506
00:34:05,490 --> 00:34:10,760
enter the address and tell the address here so I can actually for example and enter an address.

507
00:34:10,770 --> 00:34:16,670
So for example I can say Los Angeles OK Los Angeles.

508
00:34:16,800 --> 00:34:19,160
And it says Enter miles per hour.

509
00:34:19,400 --> 00:34:23,320
So I can say for example six feet and 10 meters per mile.

510
00:34:23,360 --> 00:34:25,450
So I can say for example 40.

511
00:34:25,670 --> 00:34:26,150
Right.

512
00:34:26,360 --> 00:34:32,630
But here let's actually just disappear at this virtual keyboard.

513
00:34:32,630 --> 00:34:37,310
Let's click on the spot and get the data and let's wait.

514
00:34:37,340 --> 00:34:39,440
As you can see nothing happened here.

515
00:34:39,440 --> 00:34:40,790
Let's click on it again.

516
00:34:41,270 --> 00:34:42,410
Nothing happened.

517
00:34:42,410 --> 00:34:50,300
So at this point I want it actually to let you know that as an Android Developer you may always encounter

518
00:34:50,300 --> 00:34:52,180
bugs in your applications.

519
00:34:52,190 --> 00:34:52,490
OK.

520
00:34:52,490 --> 00:34:57,800
When you want to actually for example create a very complex Android application you may always actually

521
00:34:57,800 --> 00:35:00,350
encounter different kinds of box.

522
00:35:00,500 --> 00:35:05,330
And the most important lesson here there is that do not panic.

523
00:35:05,480 --> 00:35:05,860
OK.

524
00:35:06,020 --> 00:35:12,340
You just need to find the bug and you are going to actually eliminate that bug.

525
00:35:12,620 --> 00:35:15,430
And the application is going to work to work fine.

526
00:35:15,620 --> 00:35:15,970
OK.

527
00:35:16,040 --> 00:35:17,030
Do not panic.

528
00:35:17,180 --> 00:35:18,660
So our application has a bug.

529
00:35:18,680 --> 00:35:21,890
As you can see our application actually didn't respond.

530
00:35:21,890 --> 00:35:22,940
Nothing happened.

531
00:35:22,970 --> 00:35:23,830
So there is a bug.

532
00:35:23,880 --> 00:35:25,900
I just need to find that bug.

533
00:35:26,210 --> 00:35:32,030
And the first important point that I want to tell you let you know is that there's that.

534
00:35:32,050 --> 00:35:35,540
But these have happened in the event that actually exists.

535
00:35:35,570 --> 00:35:40,430
So I actually pressed on that get the data button nothing happens right.

536
00:35:40,430 --> 00:35:44,440
So the bug must be inside the actually on each method.

537
00:35:44,670 --> 00:35:45,320
OK.

538
00:35:45,350 --> 00:35:46,400
That's what I'm guessing.

539
00:35:46,400 --> 00:35:46,610
OK.

540
00:35:46,610 --> 00:35:50,760
I'm not actually 100 percent sure that the bug is inside this method.

541
00:35:50,780 --> 00:35:56,530
I'm just guessing that the bug is inside it and if it inside the curly braces of this Anchal each method.

542
00:35:57,020 --> 00:36:00,640
And let me tell you that the bug is in line number 82.

543
00:36:00,950 --> 00:36:01,540
OK.

544
00:36:01,760 --> 00:36:06,700
Instead of initializing the destination location address I mistakenly.

545
00:36:07,110 --> 00:36:11,160
And actually I just did it on purpose.

546
00:36:11,200 --> 00:36:11,400
OK.

547
00:36:11,420 --> 00:36:17,210
I just wanted to let you know about the not panicking when you actually encounter a bug in your application

548
00:36:17,480 --> 00:36:23,040
and you just need to find that Bhagvad it actually exists and just eliminate it.

549
00:36:23,330 --> 00:36:23,910
Right.

550
00:36:23,930 --> 00:36:27,210
This is actually called debugging capability.

551
00:36:27,210 --> 00:36:34,360
I want to increase your Akiba it debugging capability so that the bug happens here actually although

552
00:36:34,370 --> 00:36:38,510
our application didn't crash but it didn't work fine also.

553
00:36:38,630 --> 00:36:45,760
So let's actually solve this bug here instead of assigning destination location address to this out

554
00:36:45,760 --> 00:36:49,690
of this value I need to say this.

555
00:36:49,800 --> 00:36:51,670
Let me actually comment on this line of code here.

556
00:36:51,680 --> 00:36:54,450
I need to say destination location address.

557
00:36:54,470 --> 00:36:59,940
This is actually an instance variable that we created inside this main activity class assignment operator.

558
00:36:59,980 --> 00:37:05,610
Now I can assign address value to the destination location address.

559
00:37:05,620 --> 00:37:06,550
Right.

560
00:37:06,830 --> 00:37:13,520
Because in line number 76 inside this uncle if are getting the value of this it is the address here.

561
00:37:13,850 --> 00:37:17,460
And we are assigning get to this address value which is of type string.

562
00:37:17,720 --> 00:37:23,540
Inside this statement we want to sign that at least value as the destination location address so that

563
00:37:23,810 --> 00:37:25,650
these two values are actually equal.

564
00:37:25,710 --> 00:37:27,800
Ok the same.

565
00:37:27,800 --> 00:37:30,720
So now let's run our application again.

566
00:37:30,740 --> 00:37:34,930
Let me actually stop the program and let me run the app again.

567
00:37:35,190 --> 00:37:38,570
And let's actually choose the emulator and let's click on OK.

568
00:37:38,930 --> 00:37:40,460
Let me show you the emulator.

569
00:37:40,760 --> 00:37:42,190
So now our application is running.

570
00:37:42,200 --> 00:37:44,240
Let's again enter an address.

571
00:37:44,240 --> 00:37:52,690
Los Angeles enter mph so I can say for example 60 centimeters paramount so I can say for example 40.

572
00:37:52,790 --> 00:37:53,180
Right.

573
00:37:53,300 --> 00:37:54,780
Let's actually disappear.

574
00:37:54,800 --> 00:37:58,020
It's actually a virtual keyboard a keyboard disappeared.

575
00:37:58,070 --> 00:38:00,310
And let's click on button get the data.

576
00:38:00,590 --> 00:38:05,050
Let's wait and now again nothing happened.

577
00:38:05,250 --> 00:38:05,670
OK.

578
00:38:05,730 --> 00:38:11,690
So why actually nothing happened here because we are actually using this app on an emulator.

579
00:38:11,850 --> 00:38:12,320
OK.

580
00:38:12,500 --> 00:38:18,060
And it emulator is not actually able to actually get the use of its current location so that we cannot

581
00:38:18,060 --> 00:38:24,240
actually specify the distance for the time to get to the destination location which is actually Los

582
00:38:24,240 --> 00:38:25,190
Angeles.

583
00:38:25,230 --> 00:38:30,960
So there is a problem here because the location they use a current location is going to be null and

584
00:38:31,020 --> 00:38:34,320
it's not going to actually specify any values for these two takes viewers.

585
00:38:34,380 --> 00:38:39,690
So let's actually test this out on our own actual device so I'm going to test it on my own actually

586
00:38:39,700 --> 00:38:42,830
works and let's see if this actually has any box or not.

587
00:38:42,900 --> 00:38:44,890
Let me actually stop the program now.

588
00:38:44,970 --> 00:38:48,830
Let me run the app and this time I'm going to choose HTC Desire.

589
00:38:48,890 --> 00:38:51,400
This is my actually my own view device.

590
00:38:51,410 --> 00:38:53,660
And when we went and with the let's get to kind of OK.

591
00:38:53,820 --> 00:38:59,400
So I tested this up on my own actual device and it works perfectly OK.

592
00:38:59,400 --> 00:39:04,920
It actually gives me the miles and it also gives me the hours and the minutes.

593
00:39:04,980 --> 00:39:07,310
So that's enough for this tutorial.

594
00:39:07,410 --> 00:39:12,370
But let's actually also delete this line of code that actually that was the previous book.

595
00:39:12,630 --> 00:39:18,400
So I think that's enough for the storyline in the next story or we can actually continue adding functionality

596
00:39:18,480 --> 00:39:19,970
to this application.

597
00:39:20,040 --> 00:39:24,910
So I want you to actually start creating your own location based application.

598
00:39:24,950 --> 00:39:30,570
I want to actually post a discussion on your application to the course and also make sure to actually

599
00:39:30,570 --> 00:39:32,660
share your quotes with other students.

600
00:39:32,670 --> 00:39:38,520
Make sure to use your own creativity in order to actually create a location based application based

601
00:39:38,520 --> 00:39:40,740
on the knowledge that you have here.

602
00:39:40,740 --> 00:39:45,510
So the nice tutorials we can actually add more functionality to this application and it's and are going

603
00:39:45,510 --> 00:39:48,240
to actually make it a production ready application.

604
00:39:48,390 --> 00:39:51,660
Thank you very much for watching and I'll see you in the next tutorial.

