Search code examples
androidgoogle-glassgoogle-gdk

Voice command for apps in Google Glass?


I have an android app developed to run on the google glass. And I run it using the adb. is it possible to give configure a voice command so that I can trigger it by saying "Ok GLASS" + "My Command" ??


Solution

  • 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,

    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" />
      
    2. And you have to create a folder called xml inside res and add a xml file named as voice_trigger_start.xml.

    3. Inside that add these lines

      <?xml version="1.0" encoding="utf-8"?>
      <trigger keyword="@string/its_me_amalan" />
      
    4. Open the values folder inside the 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 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/