0
我想要做的是做一個活動,應該能夠顯示「OK,玻璃」命令打開上下文語音命令。 我已經實現了它,但只有當我點擊活動的觸摸板。有沒有可能,當我說「好,玻璃」 - >啓動應用程序 - >然後它應該顯示我的活卡,然後出現「好,玻璃」?內容語音命令谷歌眼鏡
期待你的答案 問候
我想要做的是做一個活動,應該能夠顯示「OK,玻璃」命令打開上下文語音命令。 我已經實現了它,但只有當我點擊活動的觸摸板。有沒有可能,當我說「好,玻璃」 - >啓動應用程序 - >然後它應該顯示我的活卡,然後出現「好,玻璃」?內容語音命令谷歌眼鏡
期待你的答案 問候
這是從LiveCard
Dev Guide:
表明您MenuActivity支持上下文語音命令:
// Initialize your LiveCard as usual.
mLiveCard.setVoiceActionEnabled(true);
mLiveCard.publish(LiveCard.PublishMode.REVEAL); // or SILENT
修改您MenuActivity到通過語音流支持調用:
/**
* Activity showing the options menu.
*/
public class MenuActivity extends Activity {
private boolean mFromLiveCardVoice;
private boolean mIsFinishing;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mFromLiveCardVoice =
getIntent().getBooleanExtra(LiveCard.EXTRA_FROM_LIVECARD_VOICE, false);
if (mFromLiveCardVoice) {
// When activated by voice from a live card, enable voice commands. The menu
// will automatically "jump" ahead to the items (skipping the guard phrase
// that was already said at the live card).
getWindow().requestFeature(WindowUtils.FEATURE_VOICE_COMMANDS);
}
}
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
if (!mFromLiveCardVoice) {
openOptionsMenu();
}
}
@Override
public boolean onCreatePanelMenu(int featureId, Menu menu) {
if (isMyMenu(featureId)) {
getMenuInflater().inflate(R.menu.stopwatch, menu);
return true;
}
return super.onCreatePanelMenu(featureId, menu);
}
@Override
public boolean onPreparePanel(int featureId, View view, Menu menu) {
if (isMyMenu(featureId)) {
// Don't reopen menu once we are finishing. This is necessary
// since voice menus reopen themselves while in focus.
return !mIsFinishing;
}
return super.onPreparePanel(featureId, view, menu);
}
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
if (isMyMenu(featureId)) {
// Handle item selection.
switch (item.getItemId()) {
case R.id.stop_this:
stopService(new Intent(this, StopwatchService.class));
return true;
}
}
return super.onMenuItemSelected(featureId, item);
}
@Override
public void onPanelClosed(int featureId, Menu menu) {
super.onPanelClosed(featureId, menu);
if (isMyMenu(featureId)) {
// When the menu panel closes, either an item is selected from the menu or the
// menu is dismissed by swiping down. Either way, we end the activity.
isFinishing = true;
finish();
}
}
/**
* Returns {@code true} when the {@code featureId} belongs to the options menu or voice
* menu that are controlled by this menu activity.
*/
private boolean isMyMenu(int featureId) {
return featureId == Window.FEATURE_OPTIONS_PANEL ||
featureId == WindowUtils.FEATURE_VOICE_COMMANDS;
}
}