1

I am trying to incorporate launch voice trigger in my Android application. Another post Why is my voice command missing from the ok glass menu in XE16? was quite helpful to get me started.

There is a limited set of predefined voice commands. However, most apps have a unique app name. The list of predefined command cannot possibly cater to each application. For example, if I am working on an application called "Very Angry Birds," I cannot possibly submit a request to Google team to add this voice trigger. Is there a generic trigger that one can incorporate to help launch a specific application? Regards.

Community
  • 1
  • 1
Peter
  • 9,657
  • 12
  • 61
  • 124

2 Answers2

2

Glass takes a slightly different approach to user interaction. Instead of thinking about "what app to launch?" it focuses on "what action does the user want to do?" Similar to intents, if no other app is registered for the voice command, it will direct the command to the one registered app. If more than one is registered, Glass will prompt for which app to use to complete the command.

Using your example, someone could say "Ok Glass, play a game, very angry birds".

The list of available voice commands are at https://developers.google.com/glass/develop/gdk/reference/com/google/android/glass/app/VoiceTriggers.Command. If there are other commands you think would be useful, review the checklist at https://developers.google.com/glass/distribute/voice-checklist and request the command at https://developers.google.com/glass/distribute/voice-form

Prisoner
  • 48,391
  • 6
  • 48
  • 97
2

Prisoner is correct, but there are some implementation details that will trip you up if you are not careful.

If you wanted to [pig]gyback on play a game you would add this to your manifest, inside the intent for your main activity or service (if using a live card):

<meta-data
  android:name="com.google.android.glass.VoiceTrigger"
  android:resource="@xml/voice_trigger_start" />

And in voice_trigger_start.xml put this:

<?xml version="1.0" encoding="utf-8"?>
<trigger command="PLAY_A_GAME" />

If you use keyword instead of command as you are supposed to do when launching from custom triggers in development mode, this technique will not work!

Also note that PLAY_A_GAME is not what will show, it will actually be "play a game with ...". This speaks to what Prisoner said about Glass having a different metaphor for how a user is supposed to think about interacting with Glass. See my post script for an interesting twist on this.

Finally make sure your app name is a good one. Generally this is stored in strings.xml as follows. Whatever your app name is will show in the launcher process.

<string name="app_name">Very Angry Birds</string>

At the Glass home screeen the user will say "ok glass, play a game, Very Angry Birds".

I tested this, and this is the result:

enter image description here

One last thing, if you are the only "game" in town, in other words if you are the only app installed with the PLAY_A_GAME command, then the way to launch very angry birds is now "play a game", there is no more "with...", it is hidden when there is only one app for the command. So make sure you have a title screen in case you are the only game in town so the user knows what he just launched.

Mark Scheel
  • 2,923
  • 1
  • 18
  • 23