Google Glass Android : How can i use voice trigger from current Activity (to switch cards from cardscroller)

好久不见. 提交于 2020-01-06 16:59:27

问题


I am using a cardscrollview in an Activity to show text and pitcures on different cards.

Today i can scroll by using touchpad and swipe left or right but i want to scroll between cards using voice.

Example : when i say "next" i would like to scroll forward, and when i say "prev" i would like to scroll backwards.

I saw different answers on stackoverflow like this one or this one and it looks like you can't include GlassVoice.jar anymore (tried it but not working). I saw on google documentation that i could use Contextual voice commands but i don't really understand how to include it for my case.

I would like to have something like that :

if(voicetrigger == "next"){
    scrollForward();
}

Do you think it's possible to do ? I would be grateful if someone could help me or have ideas to make it work.

Thanks


回答1:


Implement contextual voice commands with menu items such as "Next" and "Previous." Once one of those items is triggered, call setSelection(int position) on your CardScrollView with the parameter being either the current position + 1 or -1.

Here's a sample of how I use that method in my onMenuItemSelected:

mCardScroller.setSelection(mCardScroller.getSelectedItemPosition() + 1);


来源:https://stackoverflow.com/questions/29280000/google-glass-android-how-can-i-use-voice-trigger-from-current-activity-to-swi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!