1

I have followed the exact steps from the official documentation, but I still cannot get my app to start using the custom voice command. The steps are followed are:

1 Add new string resource for custom voice command in strings.xml:

<?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name">Hello World!</string> <string name="glass_voice_trigger">start example</string> </resources>

2 Create a new XML file for voice startup definition:

<?xml version="1.0" encoding="utf-8"?>
<trigger keyword="@string/glass_voice_trigger" />

3 Request proper permissions in AndroidManifest.xml:

<uses-permission android:name="com.google.android.glass.permission.DEVELOPMENT" />

4 The manifest part looks as follows:

<service
    android:name="pl.infoshare.sample.helloworld.HelloWorldService"
    android:icon="@drawable/ic_lap"
    android:label="@string/app_name"
    android:enabled="true"
    android:exported="true">
    <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" />
</service>

Still, I am not able to start the app using the voice command. If I change to one of the predefined voice commands the app shows up on the timeline and I can start it using the voice command. Did I miss anything?

jackusz
  • 27
  • 4
  • 1
    That all looks fine. Are you sure your voice definition XML file is correctly named "voice_trigger_start.xml"? – LongZheng May 15 '14 at 13:42

2 Answers2

6

Looking through the question, I didn't see anything jump out at me as incorrect. So, I created a small sample GDK project that is launched with a custom voice command, and runs just fine on my XE17.1 device. (Bonus, it demos a low-frequency LiveCard!)

Try pulling down my sample from GitHub, and see if you can launch it with the command:

'OK Glass, start my awesome app'

Below are some of the relevant bits.

AndroidManifest.xml:

    <uses-permission android:name="com.google.android.glass.permission.DEVELOPMENT" />

    <application
            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.DeviceDefault">
        <activity
                android:name=".MainActivity"
                android:label="@string/app_name"
                android:immersive="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

        <service
                android:name=".LowFreqLiveCardService"
                android:enabled="true"
                android:exported="true"
                android:icon="@drawable/ic_launcher"
                android:label="@string/app_name">
            <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"/>
        </service>

    </application>

</manifest>

res/xml/voice_trigger.xml:

<?xml version="1.0" encoding="utf-8"?>
<trigger keyword="@string/custom_keyword" />

res/values/strings.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">Low Freq Demo</string>
    <string name="heart_rate">Heart Rate</string>
    <string name="custom_keyword">start my awesome app</string>

</resources>

Here's a link to the voice command documentation, it still provides instructions on using custom voice commands. And, from my testing, they still do work.

ejf
  • 619
  • 6
  • 13
-3

Custom voice commands require, since a couple of versions ago, the aproval from google. You can send a request for that aproval from the glass developer site.

Review this.

Community
  • 1
  • 1
DavidMM
  • 21
  • 1
  • thanks, I thought that in post X16 versions creating your own voice commands is still possible for development purposes – jackusz May 15 '14 at 11:46
  • @jackusz But your title says version: XE17.1, so that is newer. – Max May 15 '14 at 12:01
  • Registered voice commands require approval from Google. Custom commands should still work in development, as the original poster mentioned in point 3. The link you provided says so as well, as does this question/solution from Glass staff: http://stackoverflow.com/questions/23097828/why-is-my-voice-command-missing-from-the-ok-glass-menu-in-xe16. I do not think this is a correct solution. – Prisoner May 15 '14 at 13:33
  • This answer is not correct. I ran through the steps outlined in the docs for custom voice commands and it works just fine. I'm not sure what jackusz is having trouble with, but it is possible to do this. https://developers.google.com/glass/develop/gdk/starting-glassware – ejf May 15 '14 at 16:02