简述:如何检查语音录制是否已在其他应用程序中后台运行。
详细:如果原生应用程序“语音记录器”中已经在后台运行语音记录,则现在我已将语音记录实现为我的应用程序的一个功能。
问题:当我尝试同时在我的应用程序中进行录制时,它会出现错误:
: 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)
RecordMyVoice.java文件中第100行的代码:
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
问题在于因为已经有语音记录在后台运行,所以有没有办法停止语音记录,如果它正在其他应用程序中运行。
任何输入都将是巨大的帮助。
prepare
和start
抛出的异常。 - Michael