MediaRecorder启动失败了

时间:2015-03-31 23:19:48

标签: android android-mediarecorder

我正在尝试在Android中接受电话时记录通话。

为此,我创建了一个Receiver,因为我保留了MediaRecorder这样的初始设置代码..

onReceive(){

    recorder = new MediaRecorder();
    outputFile = Environment.getExternalStorageDirectory().
                      getAbsolutePath() + "/myrecording"+System.currentTimeMillis()+".3gp";

    recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);
    recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
    recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); 
    recorder.setOutputFile(outputFile);

 }

并在phoneState更改侦听器中,针对案例OFF_HOOK

case TelephonyManager.CALL_STATE_OFFHOOK: {
    Log.v(TAG,"call state is OffHook");
    try{
        recorder.prepare();
        Thread.sleep(1000);
        recorder.start();

    } catch(Exception e) {
        Log.e(TAG,"Error occured here");
    }
    break;
}

每次控件进入此状态时,我都会收到错误消息

E/MediaRecorder(23056): start failed: -2147483648
W/System.err(23056): java.lang.RuntimeException: start failed.

我试过了this,但它也无法正常工作,请你帮帮我吧。谢谢

0 个答案:

没有答案