是否可以使用语音命令进行导航,而不是使用滑动手势? [英] Is it possible to using voice commands for navigating instead of using swipe gesture?

查看:139
本文介绍了是否可以使用语音命令进行导航,而不是使用滑动手势?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我开发一个应用程序浸泡提供在屏幕和用户文本可以swipe_right去另一个。

Currently, I'm develop an immersion app to provide a text on screen and user can swipe_right to go another one.

其实,它从名为哑谜(谷歌开发网站样品浸泡模式适应)。

Actually, It adapt from sample immersion pattern called charades(google development site).

我的目标是,我想使用的,而不是滑动手势语音命令。

My objective is, I want to using voice commands, instead of SWIPE gesture.

例如;


  1. 用户打开浸泡演示,屏幕上会显示第一个文本。

  2. 用户想要通过的使用声音下一步是什么去下一个文本

  3. ,屏幕显示另一个文本。

考虑到这<一href=\"http://stackoverflow.com/questions/21652321/how-to-navigate-a-google-glass-gdk-immersion-application-using-voice-command-onl?rq=1\">post!

有没有办法做到这一点?
或任何建议?

Is there any way to do this? or any suggestion?

推荐答案

在这里,这是我的解决方案。希望这可以帮助别人谁期待的。

Here, It is my solution. Hope this might helped someone who looking for.

我用内容相关的语音命令来提供下一步,保存和退出为用户命令。你可以去从谷歌开发站点本文看到的想法这样做。

I used Contextual voice commands to provide 'Next', 'Save' and 'Exit' commands for an user. you can go to this document from google dev site to see the ideas of doing this.

我有我的布局的活动的显示一些文本,所以我把这个code结构。在我的布局活性

I have my layout activity to show some TEXT, so I put this code structure. in my layout activity

    //contextual voice command
import com.google.android.glass.view.WindowUtils;
import android.view.Menu;
import android.view.MenuItem;


@Override
public boolean onCreatePanelMenu(int featureId, Menu menu) {
    if (featureId == WindowUtils.FEATURE_VOICE_COMMANDS) {
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
    // Pass through to super to setup touch menu.
    return super.onCreatePanelMenu(featureId, menu);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
    if (featureId == WindowUtils.FEATURE_VOICE_COMMANDS) {
        switch (item.getItemId()) {

            case R.id.save_menu_item:
                Log.d("Contextual", "go save checks");  
                break;
            case R.id.next_menu_item:
                Log.d("Contextual", "go next checks");                    
                break;
            case R.id.exit_menu_item:
                Log.d("Contextual", "go exit checks");                    
                break;
            default:
                return true;
        }

        return true;
    }
    return super.onMenuItemSelected(featureId, item);
}                                                                                                                

不要忘记的声明此行 getWindow()requestFeature(WindowUtils.FEATURE_VOICE_COMMANDS); 您的onCreate();在你的的setContentView()

Don't forget to declare this line getWindow().requestFeature(WindowUtils.FEATURE_VOICE_COMMANDS); to your onCreate(); before your setContentView().

接下来的事情,我创建菜单文件夹和的main.xml 其内部提供本人选择的项目。像这样

Next thing, I created 'menu folder' and main.xml inside its to provide my item selection. Like this

<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
    android:id="@+id/next_menu_item"
    android:title="@string/next">

</item>
<item
    android:id="@+id/save_menu_item"
    android:title="@string/save_this">
</item>
<item
    android:id="@+id/exit_menu_item"
    android:title="@string/exit">
</item>

和我的的strings.xml 文件。

<resources>
   <string name="next">next</string>
   <string name="save_this">save</string>
   <string name="exit">exit</string>
</resources>

把这行
&LT;使用许可权的android:NAME =com.google.android.glass.permission.DEVELOPMENT/&GT;

你的 AndroidMenifest.xml

,它为我工作得很好!

这篇关于是否可以使用语音命令进行导航,而不是使用滑动手势?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆