How to Implement Voice Command in Android Watch

How to Implement Voice Command in Android Watch

Voice commands are very important for smart watches as users do not like to
interact with a small screen watch by tapping.In this short article I will explain
how to implement voice command capability in an Android Watch application.

1) App Provided Voice Action.

For example say “RunActivity” is my starting activity for the watch
application.The objective is to provide a voice command like “Start
RunActivity” ,then add “android:label” as below :
<activity android:name=“.RunActivity” android:label=”RunActivity”>
<action android:name=”android.intent.action.MAIN” />
<category android:name=”android.intent.category.LAUNCHER” />

2) Free form speech input.

In addition to voice command to launch an activity , we can also provide voice
recognizer facility to recognize a voice command and then process it. For
private static final int SPEECH_REQUEST_CODE = 0;
// Create an intent that can start the Speech Recognizer activity
private void displaySpeechRecognizer() {
Intent intent = new
// Start the activity, the intent will be populated with the speech text
startActivityForResult(intent, SPEECH_REQUEST_CODE);
// This callback is invoked when the Speech Recognizer returns.
// This is where you process the intent and extract the speech text from the
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
if (requestCode == SPEECH_REQUEST && resultCode == RESULT_OK)
List<String> results = data.getStringArrayListExtra(
String spokenText = results.get(0);
// Do something with spokenText
super.onActivityResult(requestCode, resultCode, data);

Here is the link for the example project.Have fun playing with it.

This entry was posted in Android Apps and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


25,128 Spam Comments Blocked so far by Spam Free Wordpress


Please type the text above:

HTML tags are not allowed.