Hire one in this story and we're going to go inside this main activity class and we're going to actually
create a valuable model which is actually the country datasource.
So here to stay in public static.
And here just referred to the data type which is going to be country datasource and the name is going
to be country Data Source semi-colon.
So now let's go inside this and create Smurfette here.
And now I want to actually initialize this instance.
So just type in here country Data Source assignment operator new country datasource.
So here you can see that we are actually calling the constructor of this class which is going to accept
an argument of type hash table but we don't have any hash table value here.
So we need to create it create that here.
So before this line of code that actually creates an object of type of the country data source here
we need to create a variable of a hash table.
So just typing here inside is uncreate If you're just typing hash table and put a pair of angle brackets
here add in say the angle brackets we need to specify the data type of the key and values.
So just a bit here strange comma strange and the name is going to be countries and missus's assignment
operator new hash table new hash table.
That's it.
Semicolon.
So we created an object of type hash table and we assigned this object to this variable.
So this hash table variable is going to accept values actually keys and values of types 3.
So now after this line of code here I can say countries and messages that puts So here and calling that
method put on this hash table right here.
So you can see this Myford pute needs two arguments.
The first argument is going to be off the string which is going to be the key.
And the second argument is going to be off Eppstein which is going to be the value.
So just put two coats here.
And for the cutest they've been here for example Canada Canada comma and the value is going to be just
two coats.
Welcome to Canada.
Semicolon.
Let's actually again just refer to this hash table label countries and messages that put just put two
coats here.
This term just that refers to this France.
Come on.
And for example for the message I can say welcome to France.
Welcome to France.
Happy visiting or I can't say happy semicolon here for this channel for instance.
I can also say happy visiting happy and here again countries and messages that put so at this time.
For example I can't say Brazil Brazil come on two coats will come to Brazil
happy visiting semicolon countries and messages that puts two coats.
United States United States Khama two coats.
Come to United States happy visiting semi-colon.
And here let me create a new line so that you can see what's going on here.
I could also put other countries here.
So I just say in countries and messages that puts two coats for example Japan come on two coats.
Welcome to Japan.
Happy visiting semi-colon.
So that's it is are the countries that I specified here if you want to you can actually specify more
countries but as an example I just specify these countries here.
So now that we have this hash table variable which then passed to the constructor of this country data
source class.
So I can actually pass this value.
Countries and countries and messages here to this constructor's semicolon.
So now we created a new instance of country data source and we assigned this instance to this country
Data Source variable.
Right.
So now let's go to the on activity results method here.
Let's scroll down here so here you can see that we're actually getting there.
Actually the voice words from their voice intent and we are also getting the confidence levels of our
voice recognition framework.
So you know what is this confidence level it is actually related to the preciseness of each word that
is said by the user.
OK.
And here we can see that they created a variable of that integer and we created a for loop in order
to access these words and output them to the screen.
But here we don't want to actually access the user words and output the output to the screen because
here we are actually working with a map right.
So I want to actually for example if the user says Canada I want a market to be created on the Canada
country and I want that message to be shown to the user.
So here we don't need these integer value but and this for in loop here.
So let's highlight these lines of code here.
This rally but this were in loop and let's delete these codes.
Or for example I can actually create a comment Amante line come in.
So it's actually I'm going to create multiline comments so here you can see that these codes are actually
commented out.
We're not going to work with these codes anymore.
So now I'm going to actually for example put to put more quotes here put my own logic here and here
you are going to see that you're going to work with the map by using this speech recognition framework.
So let's see how we can do that.
So here let's create a variable of type streams.
And the name of this variable is going to be country country.
Matched right.
Assignment operator and now I'm going to refer to the country Data Source instance that match with minimum
confidence level of user votes.
So we are calling this an effect on this instance.
And here you can see that we need to pass a value of tape released to the Smurfette and we need to also
pass the confidence levels.
So we already have these values.
Your voice forth and comfort levels.
So I can actually as an as the first argument I can pass.
Voice words come on.
And as the second argument I get past the conflict levels it's just I think he had conflict levels semicolon.
So let me create a new line here so you can see that we are calling this method in this instance voice
words comfort levels.
Now we are assigning the return value of the Smurfette to this variable of type string.
So you know that the return type of this method is actually off the street.
Right.
So the return value is a string value so it is going to be assigned to this string valuable country
matched.
So let's change this rowdier been name to country matched up with user Vort.
It's more meaningful user actually Vort.
So now I can say so here you can see that now that we have this country matched it use a reverse string
value here.
We want to pass this string value to the map activity.
So you already know that we have two activities inside our project.
The first one is the main activity and the second one is the map activity that contains the map right.
So I want to send this data for example this country must use the reward value to the math activity
so that the math activity can actually understand what is this specific award and then the map is going
to respond according to that word.
For example if the user says Canada does Canada work is going to be actually passed to the math activity
and the math activity is going to respond to this.
And it's going to actually show the user a place in Canada and it's going to show this message that
is specified in say these are created for me show you that in fifth year you can see that here.
As we said Canada Welcome to Canada happy visiting.
Right.
So let's scroll down here.
Don't worry if you don't understand it now it's going to make sense later for not just know that we
are going to actually pass.
We want to send this value to them or activity.
So after this line of code we need to create a new intent of type that actually of that intent and the
name of this intent is going to be my intent which is going to actually transition from this activity
to the map activity.
So just they've been here intent and the name of this intent is going to be my map activity my math
activity or my activity is it's more meaningful.
Assignment operator so not just step he had new intent.
So as the first argument we need to pass the context which is going to be main activity that this come
on.
There's such an argument is going to be class that we want to transition to.
But it's going to be mapped activity maps activity that class flight semicolon.
So because we want to send our data to this my math activity here I need to actually refer to this intent
to this activity that puts extra.
So as the key is you know that we created a key inside this country data source.
So let's go to this country that are sort of class here you can see that in line number 15 we created
a constant named country key here so we can actually specify this constant is actually the key here
as the key of our here of our intent.
And we can sense the state of this country must be the user of what you to the math activity class.
So I can refer.
So let me go back to this country that are class.
Notice that this is actually a constant.
And this is a static constant.
This means that this is actually class A class constant.
And by just referring to the name of the class we can call this constant on this class.
So let's go back to our main activity class and here is the key I can refer to this country data source
class country Data Source thought.
And here I can say country key if I go to this country get a classic and see that we have this country
key here.
So let's go back to main I keep the class comma.
And now I need to pass the value which is going to be related to this key and it is country matched
with user what semicolon that that create a new line so that they can see what's going on here.
And finally we need to call this Tarth activity method here.
So just step in here start actually with you notice that we are not using start activity for results
because we don't want we don't try to actually get any data from the math activity.
We just want to send this data to the map activity.
OK.
So what is that you're using this method instead on activity result.
If it does an activity it is again inside the if statement.
It is is step in it's going to be executed when the intent when the voice into it is actually finished
executing.
And it is eliminated and we are back to this main activity and here you are getting those data from
the voice intent and now inside is intent.
Instead the main activity after getting the data from the user world.
Here you can see we can actually call it start activity and we can open the map my map activity that's
it.
So now let's actually let me show you the project and review here so you can see that it is actually
in Project view.
If you are at the top just click on View tool windows project you can see that.
Now my project is in Project view here this project structure and I need to change you to Android.
OK.
So here you can see this little triangle here.
If I click on this dropdown menu I just click on this Android.
So it is actually in and with view of the app folder.
And let's open the manifest for that just double click on it this way.
Here let me turn this tap here so let me scroll down here so you can see that we have two activities.
The first one is the main activity here.
And the second activity is this tech here which is for the mass activity.
So previously we specified that this mass activity is going to be the launcher activity right.
Because of this intense to attack here we are satisfied that it is going to be the main action and it
is going to be the luncher activity.
So now we want to actually say that now the main activity is going to be the larger activity not this
maps activity.
So here for this mapping activity here just a select or highlight this intent intent to filter here
this intent to attack just highlighted and just cut this piece of code and let's scroll to the top.
And for this activity here for this main activity inside this tag place this value here.
So now the main activity is the lantern activity.
If you run the application here now you can see that it's going to actually open the main activity first.
Let me run the app now so it is actually choosing the Nexus API.
And I should say if are 25 that's really kind of cool.
So here you can't see that or app is running on the simulator.
And now you can see that the main activity is there luncher activity.
So let's go back to android studio.
We're not finished yet.
You can see that inside the main activity here.
And inside these are like TVs result we get the user vort and we send this data to the mouse activity
and now we actually opened the math activity right.
But now we need to go to the maps activity class and here inside this class we need to handle the responses
we need to actually handle the data that we get from the main activity class.
So how we can do that.
So I think that's enough for this tutorial in the next tutorial we can actually work with this working
inside this mass activity class.
If you have any questions please post the discussion in the course and then I do my best to answer all
of your questions.
Thank you very much for watching and I'll see you in the next tutorial.