Search code examples
androidvoice-recognitiongoogle-glassgoogle-gdk

Create "ok glass" style menu, within glass app


I have just begun developing for Google Glass, and I knew the GDK if fairly new so this may not be possible yet, but here's what I'm trying to to:

As with the "make a call" prompt or the "send a message to" prompts on the "okay glass" screen, I would like my app to have more voice selected options when you select it with your voice. With the two examples, you will see a list of contacts, which you can nod your head up and down to see more of, and the app will only take further actions one you've selected one of the displayed choices. Is there currently any way to do that on my own app?

Any input is appreciated!


Solution

  • You can call an intent to display the Voice Recognizer after your Activity has started. So, you could have your voice trigger and prompt from the launch, and then, in your Activity's onResume(), call the Voice Recognizer, with some kind of prompt (or you could just string the initial speech collected into this as the prompt):

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

    You then would need an onActivityResult() method to process the return form the VoiceRecognizer.

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

    Not sure if there is any other way.