Search code examples
androidgoogle-glassgoogle-gdk

How do I show icons for oncreate menuitems in google glass "ok glass" voice menu inside the activity?


I am trying to display icons for menu items created in an activity in google glass application. Here is my code.

if (featureId == WindowUtils.FEATURE_VOICE_COMMANDS) {
getMenuInflater().inflate(R.menu.voice_menu, menu);
return true;
}

And my menu.xml

<menu xmlns:android="http://schemas.android.com/apk/res/android" >

    <item
        android:id="@+id/navigate"
        android:title="Navigate"/>
    <item
        android:id="@+id/back"
        android:icon="@drawable/icon2"
        android:title="Back"
        android:showAsAction="always|withText"/>
</menu>

But if i say "ok glass" it will show only menu title, no menu icon is shown. Please help me to proceed.


Solution

  • With the "Ok Glass" menu (named Contextual Voice Command), you can't add any icon With XE19 you can't add more than 6 items and custom the display of the "Ok Glass".

    If you put an icon in your menu.xml, this icon will only appear if you use a classic menu calling this function :

    openOptionsMenu();
    

    If you use a voice command menu using the code below, the icon won't appear :

    getWindow().requestFeature(WindowUtils.FEATURE_VOICE_COMMANDS);