我使用意图语音识别,这是代码:
/**
* Fire an intent to start the voice recognition activity.
*/
private void startVoiceRecognitionActivity()
{
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Voice recognition Demo...");
startActivityForResult(intent, REQUEST_CODE);
}
一切正常。现在我想在5秒后停止语音识别。我无法想象如何杀死语音识别活动。
答案 0 :(得分:2)
要停止语音识别活动,请拨打finishActivity(REQUEST_CODE)
因此,您需要在onFinish
来电finishActivity(REQUEST_CODE)
中设置一个持续5秒的倒数计时器。致电startActivityForResult