Android:Mediarecoder 在 start() 中抛出 IllegalStateException

Android: Mediarecoder is throwing IllegalStateException in start()

我想在我的应用程序中使用 mediarecorder 来录制语音。 我完全按照 http://developer.android.com/reference/android/media/MediaRecorder.html 中的描述进行操作,但是 exception 总是在 start() 方法中抛出。 代码应该没问题,因为我还尝试了 google 中名为 Mediarecorder 的代码示例,但我得到了相同的 exception:

mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setOutputFile(mFileName);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

    try {
        mRecorder.prepare();
    } catch (IOException e) {
        Log.e(TAG, "prepare() failed");
    }
    mRecorder.start();

我已将权限 (android.permission.WRITE_EXTERNAL_STORAGE and android.permission.RECORD_AUDIO) 添加到 AndroidManifest.xml, 并在已连接的智能手机上启动该应用程序。

有谁知道 Exception 可能导致什么以及必须做什么?

感谢您的评论。我能够解决这个问题。我实际上缺少一个 mRecorder.release() ,所以似乎启动方法被调用了两次。