0
내가하려는 것은 문맥 음성 명령을 여는 "ok, glass"명령을 표시 할 수있는 활동을 만드는 것입니다. 나는 활동의 터치 패드를 밟을 때만 이미 그것을 달성했다. "OK, 유리"-> Start App ->라고 말하면 내 라이브 카드가 나타나야하고 "ok, glass"가 나타날 가능성이 있습니까?상황 별 음성 명령 Google Glass
인사말
내가하려는 것은 문맥 음성 명령을 여는 "ok, glass"명령을 표시 할 수있는 활동을 만드는 것입니다. 나는 활동의 터치 패드를 밟을 때만 이미 그것을 달성했다. "OK, 유리"-> Start App ->라고 말하면 내 라이브 카드가 나타나야하고 "ok, glass"가 나타날 가능성이 있습니까?상황 별 음성 명령 Google Glass
인사말
이에서 당신의 답변을 기대 찾고 LiveCard
Dev Guide :
// 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;
}
}