Update - After XE16 update the following method does not work, the new solution is here Why is my voice command missing from the ok glass menu in XE16?
What you have to do is,
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" />
And you have to create a folder called xml inside res and add a xml file named as
voice_trigger_start.xml
.Inside that add these lines
<?xml version="1.0" encoding="utf-8"?> <trigger keyword="@string/its_me_amalan" />
Open the values folder inside the
res
folder and editstrings.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 onto Glass and say "ok glass, Hello Amalan" and the app opens.
Reference: http://pathofacoder.com/2013/11/20/google-glass-adding-your-own-voice-commands-to-your-apps/