Google Glass – Adding your Own Voice Commands to Your Apps

Hey guys with the introduction of the Glass development Sneak Peek, I found the way to add your own voice command to trigger your app. This is for native Android Apps.

What you have to do is,

Step 1
inside the manifest file add these tags under the service which you wanted to trigger on your voice command.

<intent-filter>
<action android:name=”com.google.android.glass.action.VOICE_TRIGGER” />
</intent-filter>
<meta-data
android:name=”com.google.android.glass.VoiceTrigger”
android:resource=”@xml/voice_trigger_start” />

Step 2And you have to create a folder called xml inside res and add a xml file named as “voice_trigger_start.xml”

Step 3
Inside that add these lines

<?xml version=”1.0″ encoding=”utf-8″?>

<trigger keyword=”@string/its_me_amalan” />

Step 4
Open the values folder inside res folder and edit strings.xml, so it will look like this

<resources>
<string name=”app_name”>Amalan</string>
<string name=”its_me_amalan”>Hello Amalan</string>
<string name=”stop”>Stop</string>
</resources>

Now install the app into the google glass and say
OK GLASS Hello Amalan
And the app opens

I have used my name 😉 but you can try lots of other words.

Please install the latest  Glass Development KIT and tryout the samples, you can get more out of it 🙂

Get the Source here
gitHub-download-button

 

Advertisements

6 thoughts on “Google Glass – Adding your Own Voice Commands to Your Apps

  1. I saw a demo that while running app with voice trigger it waits for another command and then run the app for that specified input.app name is allthecooks
    How can i do that in the code?

    thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s