当 MediaRecorder 对象上的 prepare() 失败时调用 start() 是否正确?

Is it correct to call start() when prepare() failed on MediaRecorder object?

来自 android developer website 的代码片段。

即使mRecorder.prepare()失败了,调用mRecorder.start()也没有错吗?

private void startRecording() {
    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(LOG_TAG, "prepare() failed");
    }

    mRecorder.start();
}

是的,错了。

public void start () Added in API level 1

Begins capturing and encoding data to the file specified with setOutputFile(). Call this after prepare(). Since API level 13, if applications set a camera via setCamera(Camera), the apps can use the camera after this method call. The apps do not need to lock the camera again. However, if this method fails, the apps should still lock the camera back. The apps should not start another recording session during recording.

Throws IllegalStateException if it is called before prepare().

更多信息here