Android: multimedia recorder: startup failure: -38

Brief information. How to check if voice recording is running in the background in another application.

More: if voice recording is already running in the background from your own application: voice recorder. Now I have applied voice recording as one of the functions in my application.

Problem: while trying to write in my application, an error occurs at the same time:

: E/MediaRecorder: start failed: -38 : E/MyApp: [1162][com.sec.MyApp.multimedia.RecordMyVoice]java.lang.IllegalStateException : E/MyApp: at android.media.MediaRecorder.start(Native Method) : E/MyApp: at com.sec.MyApp.multimedia.RecordMyVoice.doInBackground(RecordMyVoice.java:100) 

Code on the 100th line in RecordMyVoice.java:

  mRecorder = new MediaRecorder(); mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); mRecorder.setOutputFile(mFileName); mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); mRecorder.prepare(); mRecorder.start(); //code at 100th line 

But the problem is that voice recording is already in progress in the background. Therefore, is there a way to stop voice recording if it works in another application.

Any input would be very helpful.

+4
source share
2 answers

I had the same error -38, I found out that there is another background service using the microphone through (AudioRecord), when it turned off the background service, it worked.

+1
source

Check the file path, the directory must exist.

0
source

Source: https://habr.com/ru/post/1437205/


All Articles