简体   繁体   English

Google Glass:从“活动”返回到voice_trigger / voice_prompt

[英]Google Glass : return to voice_trigger / voice_prompt from the Activity

I am new to Glass development, I have a simple application 我是Glass开发的新手,我有一个简单的应用程序

Ok Glass => Dictionary (voice_trigger) => Say a word to search (voice_prompt) => MyActivity (app) Ok Glass =>词典(voice_trigger)=>说一个字来搜索(voice_prompt)=> MyActivity(app)

If I do a SWIPE_DOWN, I go back to the first view : Ok Glass. 如果执行SWIPE_DOWN,则返回第一个视图:Ok Glass。 From my Activity, I would like to launch another research with a gesture, and go back to the voice_prompt view, without saying "Ok Glass" and "Dictionary". 从我的活动中,我想用手势启动另一个研究,然后返回到voice_prompt视图,而无需说“ Ok Glass”和“ Dictionary”。

Is it possible or do I need to avoid voice_prompt is this case ? 有可能还是我需要避免voice_prompt是这种情况?

Thanks 谢谢

In your activity, you should be able to do something like: 在活动中,您应该可以执行以下操作:

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if(keyCode == KeyEvent.KEYCODE_BACK) {
        Log.i(TAG, "BACK PUSHED");
        Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
        startActivityForResult(intent, SPEECH_REQUEST);
        return true;
    }

    return super.onKeyDown(keyCode, event);
}

By doing this, you stop the default handler for the swipe down and set your own, which causes the speech recognition activity to appear ( https://developers.google.com/glass/develop/gdk/voice#starting_speech_recognition ). 这样,您就可以停止向下滑动的默认处理程序并进行自己的设置,这会导致语音识别活动出现( https://developers.google.com/glass/develop/gdk/voice#starting_speech_recognition )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM