4
此功能啓動語音識別,但超時過早,好像語音識別 從IME鍵盤(例如Google鍵盤)啓動,它不會如此快速地超時。 我需要一種方式來啓動Google鍵盤所使用的相同意圖。語音識別超時時間過早android
public void StartSpeechRecognitionActivity(){
try{
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, getClass().getPackage().getName());
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, true);
intent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS, 3000);
intent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS, 3000);
main.startActivityForResult(intent, SPEECHRECOGNITION_RESULTCODE);
} catch (ActivityNotFoundException error) {
ShowAndSpeakMessage("Speech recognition is not supported by your device");
} catch(RuntimeException error) {
Log.e(TAG, ERROR_PREFIX + Errors.toString(error));
} catch(Error error) {
Log.e(TAG, ERROR_PREFIX + Errors.toString(error));
throw error;
}
}
沒有它不是實際上我想,這意圖超時幾秒後,而我想意圖將打開,直到用戶取消 –