Create an ok glass style menu on the stack

I was just starting to develop for Google Glass, and I knew the GDK, if it was pretty new, so this is not possible yet, but here is what I'm trying to do:

As with the request to “make a call” or “send a message” on the “okay glass” screen, I want my application to have more voice choices when you select it with your voice. In two examples, you will see a list of contacts that you can nod your head up and down to see more, and the application will only take additional actions that you select one of the displayed options. Is there a way to do this in my own application?

Any input is appreciated!

+8
android google-glass voice-recognition google-gdk
source share
4 answers

You can trigger the intention to display Voice Recognizer after starting your activity. That way, you can have a voice trigger and a request from starting, and then in your Activity onResume () call Voice Recognizer with some kind of hint (or you can just transfer the initial speech gathered in this as a hint)

Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra( RecognizerIntent.EXTRA_PROMPT, "ok glass, here my prompt" ); startActivityForResult(intent, 0); 

Then you need the onActivityResult () method to process the returned VoiceRecognizer form.

This is described in the GDK docs: https://developers.google.com/glass/develop/gdk/input/voice

Not sure if there is another way.

+2
source share

I found this answer from another SO question that seems to be what you want. I tried this myself for my own utensils and it works great. As mentioned in the answer below, you need to warn that other applications that use the same “ok glass” voice command will share the submenu; in the following example, for example, some other applications may add other games, such as golf. Another potential problem is that for each of the parameters you want in the submenu, you must have a type of activity or service.

"If there are several actions / services installed on the glass that have the same intent filter for launching voicemail, all their names (based on the android:label attribute of the <activity> or <service> in AndroidManifest.xml ) will be displayed in the" submenu "meaning when you say that voice start.

For example (suppose res/xml/play_a_game_trigger.xml represents a voice trigger for the line "play a game"):

 <activity android:label="Tennis"> <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/play_a_game_trigger" /> </activity> <activity android:label="Bowling"> <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/play_a_game_trigger" /> </activity> 

will give you a voice menu stream that looks like

 ok glass → play a game → Tennis Bowling 

Please note, however, that this menu will also include actions / services from other APKs that also use the same voice start.

You can find more details on the Voice Input page of the GDK documentation page. "

+2
source share

You ask, can you add a voice command to Glass that will invoke your application? If so, absolutely. This is essentially the proposed way to run the application in the GDK.

See https://developers.google.com/glass/develop/gdk/input/voice#launching_glassware for more details, but basically you'll

  • Add resources to res/values/strings.xml describing trigger and request
  • Create a resource in res/xml/<my_voice_trigger>.xml that uses a string value as a keyword and sets an input prompt
  • Register intent filter for action VOICE_TRIGGER

(Aside, it seems that verbs are the best voice triggers to use - they flow more naturally with the item “ok, glass”.)

0
source share

Now you can use the apis framework to display the ok menu in your activity, check out these Contextual Voice Command Documents

https://developers.google.com/glass/develop/gdk/voice#contextual_voice_commands

0
source share

All Articles