android: media recorder : start failed: -38

浪子不回头ぞ 提交于 2019-12-12 12:29:06

问题


Brief: How to check if voice recording is already running in background in some other app.

Detail: if voice recording is already running in background from native app: Voice recorder. Now I have implemented voice recording as one of feature in my application.

Problem: when i try recording in my app at the same time, it gives error :

  : 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 at 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 problem is because already voice recording is running in background. Therefore is there any way to stop voice recording if its running in some other app.

Any input would be of great help.


回答1:


i've had the same Error -38, i found out that there is Another background service that uses the mic via (AudioRecord), when disabling the background service , it worked.




回答2:


Check your file path, the directory must be existed.



来源:https://stackoverflow.com/questions/12675120/android-media-recorder-start-failed-38

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!