Hire everyone in this material we're going to go ahead and we're going to create a new app called Map
speech app.
So before that we need to make sure that our SDK components are actually updated.
So here click on configure and then click on STK manager.
So now you can see that is the case manager is open for us.
Make sure that you have actually downloaded the Android 7 point 1.1 target or Android 7.0 or Android
6 0 a marshmallow here or above and then make sure to actually click on these STK tools pop here.
So here make sure to actually have this Android SDK tools installed.
We have this android emulator.
You can see that the update is available.
So I'm going to update it here and we can see you can see that the Android platform tool.
Here is updates are available here.
Make sure to update this one too.
So let me actually first show you all these components.
So here let's scroll down.
Here you can see this one here support repository.
And you can see that the Google repository is actually that you have you can see this update is available.
Make sure to also update this one too.
In other words let's actually check this support repository here.
This package.
And now let's scroll to the top and you can see that this one Google Play services here.
We can also update this package here.
Check this check box and Android as is the case platform tools.
Make sure to also check the street check box.
And this one and emulator.
So here let's just click on apply here.
And it says the following components will be installed Android platform tools version this one twenty
five point zero point six.
And all these other components Android emulator Google Play services and Google repository these are
the necessary components that we need in order to actually create this application that we're about
to create.
So let's click on OK.
And now it's going to start actually updating these components for us.
So I'm going to post the video and then I'm going to actually just again start recording the video after
these components are updated.
So now that those are necessary components are actually updated.
Let's create an android studio project.
So the application name is going to be app 79 app 79.
You can name it whatever you want but I'm going to actually name it in this way.
17:9.
And then here you can specify the company domain to package name and a projected location.
So just click next and here choose a 16 Android 4.1 jellybean for phone and tablet just click next and
here choose any activity next.
So here you can specify the activity and make sure that this checkbox is actually checked to generate
lay out file.
Lay out name is activity and underline main and make sure that this checkbox here is also checked backwards
compatibility ABC1 but just click Finish.
So let's wait a little bit here.
So now that the project is created Let's go to our outfight activity and element of the exam.
So here make sure to actually open these and review here.
And if you don't have this android view you can't just click on these two little triangles here you
can see this dropdown menu and then you can actually click on Android.
OK.
So let's open the rest folder and then open the layout folder.
Double click on this activity underline minute exam here.
So now let's double click on that in order to make this area wider so let's select this hello world
text view and then present it on your keyboard.
And here I want to switch to the take a stab at instead of constrained to lay out I'm going to change
it to relatively fast.
So just sitting here relatively out and you can see that the ending here is also relatively out.
So let's go back to the design tab.
Now here inside is pallet section let's click on layouts and let's strike a linearly old vertical here
into this relatively out and put it here at the center of this relatively flat.
OK.
So you can see that this linearly or it's vertical here.
It's lay out which is much apparent its length height is you can't see much apparent and the orientation
is worth the color.
Let's say that I text you into this linearly R20 cold.
So just going all here inside is Pallot section and selectees takes.
And just drag it here into these linearly out vertical.
Here let's say this takes the takes of this it takes to be at the center of this takes you so selectees
takes view here and lets you inside this property section.
Let's go to the view all properties and let's search for the gravity attribute here.
So search for gravity and let's actually find that.
Here's what it is.
This is actually the gravity attribute that we actually make a wider.
So open this gravity here by just clicking on this little triangle here.
And check this checkbox that says Center horizontal.
Now we can see that the text of this text view is under center at the center of the state's view.
Right.
So let's actually here scroll down here and let's click on view fewer properties and specify an idea
for the states.
The idea is going to be the value and then present until General keyboard.
So that's it.
Let's go to our main activity class here.
So here first of all we want to actually work with the speech recognition library with a speech recognition
framework actually.
So inside this class we need to create a constant.
Actually that is called a request.
So just they've been here private static final INT and the name of this constant here is going to be
speech requests so make sure that the name of this constant is capitalized.
Here is actually the convention the name of your constants always should be capitalized speech underline
request.
Right.
And here put an assignment operator and assign the value number 10 to this constant.
This is the request right.
It doesn't matter what value you assign to this constant.
The value the number that you assign to this constant must be unique.
So I assign the value number 10 to this constant.
So here first of all let me tell you that this application must be tested on a real Android device.
You cannot test this app on an emulator because the emulator does not support speech recognition.
So make sure that you have actually connected your Andretti voice to your computer and hear first inside
this uncreate method.
We must make sure that the user's device does actually support speech speech recognition.
So in order to do that we need to actually access the package manager so to step in here.
Package Manager and the name of this variable is going to be package manager assignment operator.
And here I can say this.
So this refers to an instance of type main activity.
So notice that when ever that we actually run the application.
And whenever the main activity is called and the main activity or the activity on Allemagne at this
time it is actually on the screen an instance of the main activity class is going to be created.
So this refers to that instance.
So does that get package manager.
So in this way we can access the package manager here and then let's create an new line here and here
we need to access the information of the device.
So we need to create a value of type list here.
So notice that the list is actually an interface so just put up a pair of angle brackets and instead
of angle brackets we need to specify that data type of the objects that are going to be inside this
list which is going to be resolved in full resolve in full.
And let me now let me show you the Android documentation.
So here it is the android documentation.
So inside the search bar here search for results in full right and it says and read AP eyes and do it
that content that PM that result in for just click on this one here.
So it says probably class resolve in 40.
So this is actually a class that extends the object class and implements the parsable interface.
So look at this description here it is information that is returned from resolving an intent against
an intent filter.
This partially corresponds to information collected from the and manifest that XML so let's scroll down
here.
Look at the summary here and here you can see all these actually the values here.
Right.
So let's go back to android studio.
You can if you want to you can actually read these with this documentation here but I'm going to go
back to android studio and here I can see a list.
So the name of this valuable it's going to be a list of information assignment operator and now I'm
going to access the package manager rowdier but that I created here so I can say package manager dot
Querrey intent activities.
So select this one.
He had that query into the activities.
So now let's go back to android documentation here and had inside the search bar here just typing here.
Package Manager package manager.
And here he can see this one here.
And with that content that PM the package manager just click on this one here.
So this is our package manager class.
This is actually an abstract class.
Right.
So here let's look at this documentation.
This description it says class for retrieving various kinds of information related to the application
packages that are currently installed on the device.
You can find this class pro-death package manager.
So let's search for the query intent activities.
So here if you are using a match you can't just hold down the comment and then press on that.
If on your keyboard or if you are using a Windows machine just to hold down the control on your keyboard
and then press on that if on your keyboard and here inside the search.
But again it says for Querrey intent activities so this is the method that you're looking for.
So if it says retrieve all activities that can be performed for the given intent.
Right.
So why we are calling this method because we want to make sure that we can actually access the speech
recognition capability of the device.
So let's go back to android studio here and let's let me show you first that this if it accepts two
arguments the first one is of the intent and the second argument is actually of the integer.
And it is flaks.
So let's go back to our studio.
So we need to pass these two arguments to this method here.
So for the intent here let me create a new line and just step in here.
New intent because we must pass a value of intent here to dismiss it for the first argument.
So new intent and here instead Apprentice's of this intent we are actually calling the constructor of
this intent here.
Right.
So in that Apprentice's I can say recognize their intent.
So just they can recognize their intent.
So let's let me actually show you the and regimentation.
So here inside this search spirals so just referred to this recognizer intent here recognizer intent
and Royte that speech that recognize that intent.
Just click on it.
So here you can see that this is actually a class that extends the object class.
Right.
So now let's look at this description it says constants for supporting speech recognition for thought
and intent.
This is very important constants for supporting speech recognition for starting an intent.
So this means that we must start an intent in order to access this speech recognition.
So let's let's go back to Andrew's studio and he had to step in here.
Dot action recognize speech.
So now let's go back to android city or to other documentation actually and here let's search for action
underline recognize speech.
So we get this one here it says starts an activity that will prompt the user for a speech and send it
through a speech recognizer.
Right.
So it's going to start an activity for us this month.
So let's go back to android studio.
So here we want to actually start the actually recognize speech intent.
OK.
And here we are checking for that condition.
So here you can see that this Smurfette quirky Internet activities needs the second arguments or just
put a comma here which is going to be the flex.
So for the Flex argument just passed the value zero here and at the end of our statement we must pass.
We must put a semicolon here.
Right.
So here we are getting the information.
The list of information actually.
And here this variable holds those information.
So now we want to make sure that the users the voice does actually support speech recognition.
So here I can create an if statement so if list of information if a list of information that size is
actually greater than zero.
OK I just need to open and close this if they've been by using these curly braces.
This means that if the size of this list is actually greater than zero.
This means that the user's device does support speech recognition.
In that case you are 100 and 50 percent sure that it is true.
And we can actually create a host message that make text.
So first we need to pass the context in activity that this on.
The message is going to be your device your device doest support speech recognition speech recognition
right.
And then here put a actually an up and exclamation mark here.
So let's put a comma here.
And finally even if we just need to specify the duration of this message which is going to be the short
lived short.
And finally we need to call this show him Fifth this toast object.
So let me create a new line here so that he can see what's going on here exactly.
So this is our total message.
So what happens if the user's device does not support this speech or speech recognition.
In that case we are going to create an L statements or else I just need to open and close this statement
by using these curly braces.
Let's copy and paste this TOSed message here and put it here.
Paste it here inside this block and here for the message I can see that your device does not support
does not support speech recognition.
So let's run the app on an emulator here because I want to show you that on the emulator here just to
take this one and then click on OK.
So here it says your device does support speech recognition.
But yes it's going to actually show us dismiss this year but it's not actually exactly true.
Because in order to test this feature we must use our own real Android device.
OK.
So that's it in the next story.
We're going to continue building this application.
Thank you very much for watching.
If you have any questions about the concepts that I taught you in this lesson please post the discussion
in the course and then I do my best to answer all of your questions.