1
00:00:00,270 --> 00:00:05,760
Hire one in this story and we're going to go inside this main activity class and we're going to actually

2
00:00:05,760 --> 00:00:11,400
create a valuable model which is actually the country datasource.

3
00:00:11,610 --> 00:00:16,370
So here to stay in public static.

4
00:00:17,030 --> 00:00:24,720
And here just referred to the data type which is going to be country datasource and the name is going

5
00:00:24,720 --> 00:00:27,280
to be country Data Source semi-colon.

6
00:00:27,720 --> 00:00:31,260
So now let's go inside this and create Smurfette here.

7
00:00:32,460 --> 00:00:35,740
And now I want to actually initialize this instance.

8
00:00:35,870 --> 00:00:42,710
So just type in here country Data Source assignment operator new country datasource.

9
00:00:42,950 --> 00:00:48,830
So here you can see that we are actually calling the constructor of this class which is going to accept

10
00:00:49,130 --> 00:00:54,360
an argument of type hash table but we don't have any hash table value here.

11
00:00:54,440 --> 00:00:56,850
So we need to create it create that here.

12
00:00:56,960 --> 00:01:02,930
So before this line of code that actually creates an object of type of the country data source here

13
00:01:03,190 --> 00:01:06,010
we need to create a variable of a hash table.

14
00:01:06,230 --> 00:01:12,140
So just typing here inside is uncreate If you're just typing hash table and put a pair of angle brackets

15
00:01:12,140 --> 00:01:17,310
here add in say the angle brackets we need to specify the data type of the key and values.

16
00:01:17,330 --> 00:01:28,940
So just a bit here strange comma strange and the name is going to be countries and missus's assignment

17
00:01:28,940 --> 00:01:32,720
operator new hash table new hash table.

18
00:01:32,780 --> 00:01:33,260
That's it.

19
00:01:33,330 --> 00:01:34,280
Semicolon.

20
00:01:34,280 --> 00:01:40,170
So we created an object of type hash table and we assigned this object to this variable.

21
00:01:40,400 --> 00:01:46,500
So this hash table variable is going to accept values actually keys and values of types 3.

22
00:01:46,550 --> 00:01:55,450
So now after this line of code here I can say countries and messages that puts So here and calling that

23
00:01:55,610 --> 00:01:58,100
method put on this hash table right here.

24
00:01:58,120 --> 00:02:01,300
So you can see this Myford pute needs two arguments.

25
00:02:01,300 --> 00:02:04,470
The first argument is going to be off the string which is going to be the key.

26
00:02:04,750 --> 00:02:09,030
And the second argument is going to be off Eppstein which is going to be the value.

27
00:02:09,250 --> 00:02:10,820
So just put two coats here.

28
00:02:11,350 --> 00:02:19,460
And for the cutest they've been here for example Canada Canada comma and the value is going to be just

29
00:02:19,570 --> 00:02:20,280
two coats.

30
00:02:20,330 --> 00:02:21,430
Welcome to Canada.

31
00:02:21,680 --> 00:02:23,520
Welcome to Canada.

32
00:02:25,140 --> 00:02:26,240
Semicolon.

33
00:02:26,670 --> 00:02:33,720
Let's actually again just refer to this hash table label countries and messages that put just put two

34
00:02:33,720 --> 00:02:34,650
coats here.

35
00:02:34,650 --> 00:02:37,250
This term just that refers to this France.

36
00:02:37,470 --> 00:02:38,420
Come on.

37
00:02:38,760 --> 00:02:42,320
And for example for the message I can say welcome to France.

38
00:02:42,340 --> 00:02:44,360
Welcome to France.

39
00:02:44,700 --> 00:02:50,020
Happy visiting or I can't say happy semicolon here for this channel for instance.

40
00:02:50,040 --> 00:03:00,210
I can also say happy visiting happy and here again countries and messages that put so at this time.

41
00:03:00,270 --> 00:03:10,470
For example I can't say Brazil Brazil come on two coats will come to Brazil

42
00:03:13,460 --> 00:03:20,510
happy visiting semicolon countries and messages that puts two coats.

43
00:03:20,530 --> 00:03:28,240
United States United States Khama two coats.

44
00:03:28,290 --> 00:03:34,500
Come to United States happy visiting semi-colon.

45
00:03:34,870 --> 00:03:38,780
And here let me create a new line so that you can see what's going on here.

46
00:03:39,780 --> 00:03:42,350
I could also put other countries here.

47
00:03:43,060 --> 00:03:53,340
So I just say in countries and messages that puts two coats for example Japan come on two coats.

48
00:03:53,350 --> 00:03:54,880
Welcome to Japan.

49
00:03:54,880 --> 00:03:56,600
Welcome to Japan.

50
00:03:56,620 --> 00:03:58,630
Happy visiting semi-colon.

51
00:03:58,780 --> 00:04:03,340
So that's it is are the countries that I specified here if you want to you can actually specify more

52
00:04:03,340 --> 00:04:08,490
countries but as an example I just specify these countries here.

53
00:04:08,680 --> 00:04:15,100
So now that we have this hash table variable which then passed to the constructor of this country data

54
00:04:15,100 --> 00:04:15,880
source class.

55
00:04:15,940 --> 00:04:18,600
So I can actually pass this value.

56
00:04:18,670 --> 00:04:24,810
Countries and countries and messages here to this constructor's semicolon.

57
00:04:24,820 --> 00:04:31,360
So now we created a new instance of country data source and we assigned this instance to this country

58
00:04:31,360 --> 00:04:32,840
Data Source variable.

59
00:04:32,920 --> 00:04:33,480
Right.

60
00:04:33,820 --> 00:04:38,200
So now let's go to the on activity results method here.

61
00:04:38,200 --> 00:04:42,360
Let's scroll down here so here you can see that we're actually getting there.

62
00:04:42,520 --> 00:04:49,690
Actually the voice words from their voice intent and we are also getting the confidence levels of our

63
00:04:50,050 --> 00:04:52,730
voice recognition framework.

64
00:04:52,960 --> 00:04:58,480
So you know what is this confidence level it is actually related to the preciseness of each word that

65
00:04:58,480 --> 00:04:59,840
is said by the user.

66
00:04:59,970 --> 00:05:00,570
OK.

67
00:05:01,000 --> 00:05:06,520
And here we can see that they created a variable of that integer and we created a for loop in order

68
00:05:06,520 --> 00:05:10,330
to access these words and output them to the screen.

69
00:05:10,570 --> 00:05:17,410
But here we don't want to actually access the user words and output the output to the screen because

70
00:05:17,680 --> 00:05:21,300
here we are actually working with a map right.

71
00:05:21,340 --> 00:05:29,770
So I want to actually for example if the user says Canada I want a market to be created on the Canada

72
00:05:29,920 --> 00:05:33,950
country and I want that message to be shown to the user.

73
00:05:33,970 --> 00:05:37,900
So here we don't need these integer value but and this for in loop here.

74
00:05:37,900 --> 00:05:40,950
So let's highlight these lines of code here.

75
00:05:40,960 --> 00:05:44,590
This rally but this were in loop and let's delete these codes.

76
00:05:44,710 --> 00:05:48,370
Or for example I can actually create a comment Amante line come in.

77
00:05:48,370 --> 00:05:53,920
So it's actually I'm going to create multiline comments so here you can see that these codes are actually

78
00:05:53,920 --> 00:05:55,020
commented out.

79
00:05:55,210 --> 00:05:57,100
We're not going to work with these codes anymore.

80
00:05:57,310 --> 00:06:05,890
So now I'm going to actually for example put to put more quotes here put my own logic here and here

81
00:06:05,890 --> 00:06:10,720
you are going to see that you're going to work with the map by using this speech recognition framework.

82
00:06:10,720 --> 00:06:12,460
So let's see how we can do that.

83
00:06:12,460 --> 00:06:15,930
So here let's create a variable of type streams.

84
00:06:16,510 --> 00:06:20,670
And the name of this variable is going to be country country.

85
00:06:20,670 --> 00:06:22,240
Matched right.

86
00:06:22,320 --> 00:06:30,960
Assignment operator and now I'm going to refer to the country Data Source instance that match with minimum

87
00:06:30,960 --> 00:06:33,970
confidence level of user votes.

88
00:06:33,990 --> 00:06:36,300
So we are calling this an effect on this instance.

89
00:06:36,300 --> 00:06:42,510
And here you can see that we need to pass a value of tape released to the Smurfette and we need to also

90
00:06:42,510 --> 00:06:44,150
pass the confidence levels.

91
00:06:44,190 --> 00:06:46,410
So we already have these values.

92
00:06:46,410 --> 00:06:48,620
Your voice forth and comfort levels.

93
00:06:48,750 --> 00:06:51,550
So I can actually as an as the first argument I can pass.

94
00:06:51,570 --> 00:06:54,060
Voice words come on.

95
00:06:54,420 --> 00:06:59,880
And as the second argument I get past the conflict levels it's just I think he had conflict levels semicolon.

96
00:07:00,120 --> 00:07:06,150
So let me create a new line here so you can see that we are calling this method in this instance voice

97
00:07:06,150 --> 00:07:07,510
words comfort levels.

98
00:07:07,530 --> 00:07:15,270
Now we are assigning the return value of the Smurfette to this variable of type string.

99
00:07:15,270 --> 00:07:18,940
So you know that the return type of this method is actually off the street.

100
00:07:19,020 --> 00:07:19,470
Right.

101
00:07:19,680 --> 00:07:24,750
So the return value is a string value so it is going to be assigned to this string valuable country

102
00:07:24,750 --> 00:07:26,040
matched.

103
00:07:26,160 --> 00:07:32,000
So let's change this rowdier been name to country matched up with user Vort.

104
00:07:32,010 --> 00:07:36,000
It's more meaningful user actually Vort.

105
00:07:36,140 --> 00:07:43,250
So now I can say so here you can see that now that we have this country matched it use a reverse string

106
00:07:43,250 --> 00:07:44,540
value here.

107
00:07:44,720 --> 00:07:49,460
We want to pass this string value to the map activity.

108
00:07:49,460 --> 00:07:52,520
So you already know that we have two activities inside our project.

109
00:07:52,520 --> 00:07:59,420
The first one is the main activity and the second one is the map activity that contains the map right.

110
00:07:59,480 --> 00:08:05,810
So I want to send this data for example this country must use the reward value to the math activity

111
00:08:05,840 --> 00:08:11,690
so that the math activity can actually understand what is this specific award and then the map is going

112
00:08:11,690 --> 00:08:13,700
to respond according to that word.

113
00:08:13,730 --> 00:08:20,270
For example if the user says Canada does Canada work is going to be actually passed to the math activity

114
00:08:20,600 --> 00:08:22,980
and the math activity is going to respond to this.

115
00:08:23,000 --> 00:08:28,490
And it's going to actually show the user a place in Canada and it's going to show this message that

116
00:08:28,520 --> 00:08:33,490
is specified in say these are created for me show you that in fifth year you can see that here.

117
00:08:33,510 --> 00:08:37,160
As we said Canada Welcome to Canada happy visiting.

118
00:08:37,220 --> 00:08:37,790
Right.

119
00:08:37,910 --> 00:08:39,230
So let's scroll down here.

120
00:08:39,470 --> 00:08:45,140
Don't worry if you don't understand it now it's going to make sense later for not just know that we

121
00:08:45,180 --> 00:08:46,730
are going to actually pass.

122
00:08:46,730 --> 00:08:49,870
We want to send this value to them or activity.

123
00:08:50,080 --> 00:08:57,200
So after this line of code we need to create a new intent of type that actually of that intent and the

124
00:08:57,200 --> 00:09:03,680
name of this intent is going to be my intent which is going to actually transition from this activity

125
00:09:03,920 --> 00:09:05,100
to the map activity.

126
00:09:05,240 --> 00:09:11,780
So just they've been here intent and the name of this intent is going to be my map activity my math

127
00:09:11,870 --> 00:09:16,030
activity or my activity is it's more meaningful.

128
00:09:16,780 --> 00:09:21,960
Assignment operator so not just step he had new intent.

129
00:09:22,100 --> 00:09:27,360
So as the first argument we need to pass the context which is going to be main activity that this come

130
00:09:27,360 --> 00:09:27,740
on.

131
00:09:27,900 --> 00:09:31,430
There's such an argument is going to be class that we want to transition to.

132
00:09:31,620 --> 00:09:37,520
But it's going to be mapped activity maps activity that class flight semicolon.

133
00:09:37,980 --> 00:09:46,080
So because we want to send our data to this my math activity here I need to actually refer to this intent

134
00:09:46,110 --> 00:09:50,280
to this activity that puts extra.

135
00:09:50,340 --> 00:09:56,960
So as the key is you know that we created a key inside this country data source.

136
00:09:56,990 --> 00:10:02,130
So let's go to this country that are sort of class here you can see that in line number 15 we created

137
00:10:02,300 --> 00:10:10,920
a constant named country key here so we can actually specify this constant is actually the key here

138
00:10:11,220 --> 00:10:15,610
as the key of our here of our intent.

139
00:10:15,930 --> 00:10:21,680
And we can sense the state of this country must be the user of what you to the math activity class.

140
00:10:21,780 --> 00:10:23,060
So I can refer.

141
00:10:23,060 --> 00:10:26,060
So let me go back to this country that are class.

142
00:10:26,180 --> 00:10:29,020
Notice that this is actually a constant.

143
00:10:29,310 --> 00:10:31,710
And this is a static constant.

144
00:10:31,710 --> 00:10:34,430
This means that this is actually class A class constant.

145
00:10:34,470 --> 00:10:39,290
And by just referring to the name of the class we can call this constant on this class.

146
00:10:39,300 --> 00:10:45,270
So let's go back to our main activity class and here is the key I can refer to this country data source

147
00:10:45,270 --> 00:10:48,290
class country Data Source thought.

148
00:10:48,480 --> 00:10:53,730
And here I can say country key if I go to this country get a classic and see that we have this country

149
00:10:53,730 --> 00:10:54,420
key here.

150
00:10:54,420 --> 00:10:56,900
So let's go back to main I keep the class comma.

151
00:10:57,040 --> 00:11:03,270
And now I need to pass the value which is going to be related to this key and it is country matched

152
00:11:03,270 --> 00:11:08,450
with user what semicolon that that create a new line so that they can see what's going on here.

153
00:11:08,640 --> 00:11:13,070
And finally we need to call this Tarth activity method here.

154
00:11:13,200 --> 00:11:17,430
So just step in here start actually with you notice that we are not using start activity for results

155
00:11:17,430 --> 00:11:21,090
because we don't want we don't try to actually get any data from the math activity.

156
00:11:21,180 --> 00:11:24,130
We just want to send this data to the map activity.

157
00:11:24,210 --> 00:11:24,640
OK.

158
00:11:24,810 --> 00:11:28,050
So what is that you're using this method instead on activity result.

159
00:11:28,050 --> 00:11:31,110
If it does an activity it is again inside the if statement.

160
00:11:31,320 --> 00:11:37,620
It is is step in it's going to be executed when the intent when the voice into it is actually finished

161
00:11:37,680 --> 00:11:38,380
executing.

162
00:11:38,400 --> 00:11:43,800
And it is eliminated and we are back to this main activity and here you are getting those data from

163
00:11:43,800 --> 00:11:47,450
the voice intent and now inside is intent.

164
00:11:47,460 --> 00:11:52,160
Instead the main activity after getting the data from the user world.

165
00:11:52,160 --> 00:11:59,820
Here you can see we can actually call it start activity and we can open the map my map activity that's

166
00:11:59,900 --> 00:12:00,700
it.

167
00:12:00,740 --> 00:12:07,380
So now let's actually let me show you the project and review here so you can see that it is actually

168
00:12:07,380 --> 00:12:08,860
in Project view.

169
00:12:08,990 --> 00:12:13,020
If you are at the top just click on View tool windows project you can see that.

170
00:12:13,080 --> 00:12:19,440
Now my project is in Project view here this project structure and I need to change you to Android.

171
00:12:19,530 --> 00:12:19,980
OK.

172
00:12:20,100 --> 00:12:22,190
So here you can see this little triangle here.

173
00:12:22,200 --> 00:12:26,300
If I click on this dropdown menu I just click on this Android.

174
00:12:26,400 --> 00:12:30,220
So it is actually in and with view of the app folder.

175
00:12:30,240 --> 00:12:34,020
And let's open the manifest for that just double click on it this way.

176
00:12:34,020 --> 00:12:40,450
Here let me turn this tap here so let me scroll down here so you can see that we have two activities.

177
00:12:40,680 --> 00:12:44,050
The first one is the main activity here.

178
00:12:44,340 --> 00:12:48,480
And the second activity is this tech here which is for the mass activity.

179
00:12:48,690 --> 00:12:53,610
So previously we specified that this mass activity is going to be the launcher activity right.

180
00:12:53,610 --> 00:12:59,700
Because of this intense to attack here we are satisfied that it is going to be the main action and it

181
00:12:59,700 --> 00:13:01,590
is going to be the luncher activity.

182
00:13:01,620 --> 00:13:08,280
So now we want to actually say that now the main activity is going to be the larger activity not this

183
00:13:08,280 --> 00:13:09,320
maps activity.

184
00:13:09,600 --> 00:13:17,780
So here for this mapping activity here just a select or highlight this intent intent to filter here

185
00:13:17,800 --> 00:13:26,380
this intent to attack just highlighted and just cut this piece of code and let's scroll to the top.

186
00:13:26,390 --> 00:13:32,240
And for this activity here for this main activity inside this tag place this value here.

187
00:13:32,240 --> 00:13:35,480
So now the main activity is the lantern activity.

188
00:13:35,490 --> 00:13:41,010
If you run the application here now you can see that it's going to actually open the main activity first.

189
00:13:41,300 --> 00:13:47,010
Let me run the app now so it is actually choosing the Nexus API.

190
00:13:47,270 --> 00:13:49,760
And I should say if are 25 that's really kind of cool.

191
00:13:50,000 --> 00:13:52,840
So here you can't see that or app is running on the simulator.

192
00:13:52,850 --> 00:13:56,630
And now you can see that the main activity is there luncher activity.

193
00:13:56,840 --> 00:13:58,760
So let's go back to android studio.

194
00:13:58,940 --> 00:14:00,220
We're not finished yet.

195
00:14:00,350 --> 00:14:02,260
You can see that inside the main activity here.

196
00:14:02,360 --> 00:14:07,340
And inside these are like TVs result we get the user vort and we send this data to the mouse activity

197
00:14:07,380 --> 00:14:10,530
and now we actually opened the math activity right.

198
00:14:10,700 --> 00:14:17,750
But now we need to go to the maps activity class and here inside this class we need to handle the responses

199
00:14:17,750 --> 00:14:22,250
we need to actually handle the data that we get from the main activity class.

200
00:14:22,250 --> 00:14:23,650
So how we can do that.

201
00:14:23,660 --> 00:14:29,030
So I think that's enough for this tutorial in the next tutorial we can actually work with this working

202
00:14:29,150 --> 00:14:30,920
inside this mass activity class.

203
00:14:30,980 --> 00:14:35,540
If you have any questions please post the discussion in the course and then I do my best to answer all

204
00:14:35,540 --> 00:14:36,550
of your questions.

205
00:14:36,680 --> 00:14:39,120
Thank you very much for watching and I'll see you in the next tutorial.

