AudioRecord: start() status -38

前端 未结 4 712
旧巷少年郎
旧巷少年郎 2020-12-31 06:00

I have the following problem: I use SpeechRecognizer to identify a few words. I use the

public void onResults

method to destroy the SpeechR

4条回答
  •  盖世英雄少女心
    2020-12-31 06:36

    I checked recording state by using audioRecord.getRecordingState() as Michael commented. Normally after audioRecord.startRecording();, recordingState becomes RECORDSTATE_RECORDING. If state is not RECORDSTATE_RECORDING, I will close app.

    audioRecord.startRecording();
    int recordingState = audioRecord.getRecordingState();
    Log.i(VoiceRecorder.class.getSimpleName(), "RecordingState() after startRecording() = " + String.valueOf(recordingState));
    if (recordingState != AudioRecord.RECORDSTATE_RECORDING) {
        Log.i(VoiceRecorder.class.getSimpleName(), "AudioRecord error has occured. Reopen app.");
        System.exit(0);
    }
    

提交回复
热议问题