Search code examples
google-glassgoogle-gdk

Selectively setting voice input constraints on submenu items


As I found on a Glass Developers page, it is possible to set voice constraints to disable your voice trigger if certain features are unavailable. I thought this would work for the disambiguation submenu as well, so I tried putting a constraint on one Activity in the submenu but not the others. Instead of just disabling that one submenu item ("Choose from list"), however, this disabled the entire menu ("Make a request"). Here's my manifest and voice trigger xml resources:

AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.twintitanium.glassapps.decisionmaker"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="15"
        android:targetSdkVersion="15" />

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <service
            android:name="com.twintitanium.glassapps.decisionmaker.DecisionMakerService"
            android:enabled="true"
            android:exported="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name" >
        </service>

        <activity
            android:name="com.twintitanium.glassapps.decisionmaker.MenuActivity"
            android:enabled="true"
            android:theme="@style/MenuTheme" >
        </activity>
        <activity
            android:name="com.twintitanium.glassapps.decisionmaker.ChooseFromListActivity"
            android:label="@string/choice_from_list"
            android:icon="@drawable/ic_choose_from_list" >
            <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/make_a_request_with_network_constraint_trigger" />
        </activity>
        <activity
            android:name="com.twintitanium.glassapps.decisionmaker.RollDieActivity"
            android:label="@string/die_roll"
            android:icon="@drawable/ic_roll_die" >
            <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/make_a_request_trigger" />
        </activity>
        <activity
            android:name="com.twintitanium.glassapps.decisionmaker.FlipCoinActivity"
            android:label="@string/coin_flip"
            android:icon="@drawable/ic_flip_coin" >
            <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/make_a_request_trigger" />
        </activity>
        <activity
            android:name="com.twintitanium.glassapps.decisionmaker.YesNoActivity"
            android:label="@string/yes_or_no"
            android:icon="@drawable/ic_yes_no" >
            <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/make_a_request_trigger" />
        </activity>
    </application>

</manifest>

As you can see, I use make_a_request_with_network_constraint_trigger for ChooseFromListActivity but make_a_request_trigger for the other Activities.

make_a_request_with_network_constraint_trigger.xml:

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

make_a_request_trigger.xml:

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

(Just to clarify, "@string/glass_voice_trigger" is "Make a request".)

Is there a reason that the network constraint given to one Activity disables the entire menu, even though the other Activities don't have the same constraint? Is there another way to selectively constrain one Activity and not the others?


Solution

  • This doesn't sound like the desired behavior. Can you please file a bug on our issue tracker so we can investigate further?