我的应用尝试使用MediaRecorder API录制声音。我的开始录制方法如下所示:
public void start() {
if(this.mRecorder == null) {
try{
this.mRecorder = new MediaRecorder();
this.mRecorder.setAudioSource(1);
this.mRecorder.setOutputFormat(1);
this.mRecorder.setAudioEncoder(1);
this.mRecorder.setOutputFile("/dev/null");
} catch (RuntimeException re) {
}
try {
this.mRecorder.prepare();
} catch (IllegalStateException var3) {
var3.printStackTrace();
} catch (IOException var4) {
var4.printStackTrace();
}
this.mRecorder.start();
this.mEMA = 0.0D;
}
}
但是我收到了以下一行用户的崩溃报告:
this.mRecorder.start();
IllegalStateException堆栈跟踪是:
java.lang.RuntimeException:
atandroid.app.ActivityThread.performResumeActivity(ActivityThread.java:3493)
atandroid.app.ActivityThread.handleResumeActivity(ActivityThread.java:3533)
atandroid.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2791)
atandroid.app.ActivityThread.-wrap12(ActivityThread.java)
atandroid.app.ActivityThread$H.handleMessage(ActivityThread.java:1532)
atandroid.os.Handler.dispatchMessage(Handler.java:102)
atandroid.os.Looper.loop(Looper.java:163)
atandroid.app.ActivityThread.main(ActivityThread.java:6342)
atjava.lang.reflect.Method.invoke(NativeMethod)
atcom.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880)
atcom.android.internal.os.ZygoteInit.mai(ZygoteInit.java:770)
Causedby:java.lang.IllegalStateException:
atandroid.media.MediaRecorder.start(NativeMethod)
atmeasure.sound.decibels.SoundMeter.start(SoundMeter.java:43)
atmeasure.sound.decibels.MyActivity.start(MyActivity.java:138)
atmeasure.sound.decibels.MyActivity.onResume(MyActivity.java:521)
atandroid.app.Instrumentation.callActivityOnResume(Instrumentation.java:1270)
atandroid.app.Activity.performResume(Activity.java:6960)
atandroid.app.ActivityThread.performResumeActivity(ActivityThread.java:3470)
该应用程序正在为用户崩溃。任何帮助!