Android RecognizerIntent简单破坏

时间:2013-05-13 09:35:29

标签: android

我使用意图语音识别,这是代码:

/**
 * 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秒后停止语音识别。我无法想象如何杀死语音识别活动。

1 个答案:

答案 0 :(得分:2)

要停止语音识别活动,请拨打finishActivity(REQUEST_CODE) 因此,您需要在onFinish来电finishActivity(REQUEST_CODE)中设置一个持续5秒的倒数计时器。致电startActivityForResult

后启动计时器