Programming Voice Commands for Android
You have seen those Google commercials showing a woman opening an app to call a cab, or a little girl asking the distance of the moon from Earth. Have you ever wondered how to do that programmatically in your applications? Look no further, as I will provide a simple example for you to get started. By doing one voice command, you can do several others using Android’s speech recognition service. You might be surprised at how easy it is to use this service, and instruct your phone to do things that were otherwise somewhat tedious but now more efficient with your voice.
From Eclipse, select File > New > Project > Android Application Project to bring up the new project wizard. Enter the following information:
- Application name: The application name is what will appear in your app's title bar when running on the phone. Call this application “Simple Voice Command”.
- Project name: The project name is the name of the project (i.e. simpleVoiceCommand).
- Package Name: The package name is the main application packagefor example, com.example.helloworld. Name the top-level package com.example.simplevoicecommand.
- Build SDK: This is the target build SDK for your application. It is important to choose the latest version (i.e., API 16) so your app can run on these phones. If you specify an earlier API, your app will only run on that API or earlier. The API number corresponds to the Android operating version. For example, API 16 is for Android 4.1.
- Minimum Required SDK: Unlike Build SDK (target SDK), the Minimum SDK specifies the earliest API on which your app will run. For example, if you specify Android API 8, then your app will run on Android 2.2 (Froyo) and above (up to your Build SDK).
Next, leave the other fields on the following screens with their default values for creating the main activity and main layout file, which will be examined more later. Once you click Finish to complete your project setup, Android will create the project directories.