There are many tutorials online for adding voice recognition to an android app. They are often confusing and the publishers of the coding are never available for questions. I need a basic overview of how to add voice recognition to my app (as an answer, not a link).
There are many tutorials online for adding voice recognition to an android app. They
Share
If you want to add voice recognition to your group’s Android app it is very simple.
Throughout this tutorial you will need to add imports as you paste in the code.
OnClickListenerYou will get an error that says you have unimplemented methods. Hover over it and add the unimplemented methods. We will add to this later.
Next set up the button and listview in your java.
also add:
Next, make an OnCreate Method and set up the button and listener.
also add this method(we will set it up next)
Remember to setContentView for the xml you are showing.
Outside of your oncreate make a new method that looks like this.
Now you will have to set up your voice recognition activity by using the following code.
Next, inside your onclick method from step 2 add the activity from step 6.
Next we will have to set up another method. Copy and paste the following code.
matches is the result of voice input. It is a list of what the user possibly said. Using an if statement for the keyword you want to use allows the use of any activity if keywords match it is possible to set up multiple keywords to use the same activity so more than one word will allow the user To use the activity (makes it so the user doesn’t have to memorize words from a list) To use an activity from the voice input information simply use the following format;
NOTE: you can format the code any time by pressing ctrl+shift+F in eclipse.
Now we are going to set up our method used by the code in step 8. This code creates an intent to direct the user to a new menu. You will need another xml and java class for this. Also, remember to add an activity to your manifest.
Finally you need to set up some code that will let the user know if the mic is operational. Paste this code inside of the OnCreate method at the end.
FINAL NOTE: Voice Recognition will not work on a virtual emulator because they can’t access the mic on your computer. The voice recognition will only work with an internet connection.
This is approx. what your final code should look like in your java.