Is this possible to call ' Okay Glass' only once

125 Views Asked by At

Is this possible to call ' Okay Glass' only once rather than speaking ok glass every time before giving any voice command?

For example, I start my application and call 'Okay glass' once and start giving voice commands and switching to different activities by voice commands without repeating 'Okay glass' before each voice command.

1

There are 1 best solutions below

0
Brig Cook On

If you have a list of items where each item has a sublist, you could use a menu:

res/menu/store.xml

<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:id="@+id/store"
        android:title="Buy an item">
        <menu>
            <item
                android:id="@+id/produce"
                android:title="Produce">
                <menu>
                    <item
                        android:id="@+id/apples"
                        android:title="Apples"/>
                    <item
                        android:id="@+id/bananas"
                        android:title="Bananas"/>
                    <item
                        android:id="@+id/lettuce"
                        android:title="Lettuce"/>
                    <item
                        android:id="@+id/guava"
                        android:title="Guava"/>
                </menu>
            </item>
            <item
                android:id="@+id/meat"
                android:title="Meat">
                <menu>
                    <item
                        android:id="@+id/pork"
                        android:title="Pork"/>
                    <item
                        android:id="@+id/beef"
                        android:title="Beef"/>
                    <item
                        android:id="@+id/chicken"
                        android:title="Chicken"/>
                </menu>
            </item>
        </menu>
    </item>
</menu>

I say "Ok Glass, buy an item" and it lists a menu with "Produce" and "Meat." Then I say "Produce" (without having to say "Ok Glass") and it lists the produce in the menu. When I say "Bananas," it opens the activity for buying bananas (see this project for details on that: https://github.com/alk2pb/GlassFoley/blob/master/app/src/main/java/com/example/team8capstone/glassfoley/video/VideoActivity.java).

This answer might be relevant, too: How can I dynamically create menu items?