I\'ve faced a very strange behavior: sometimes my mediarecorder crashes with an error \"Stop failed\" and sometimes it works fine. Is there my fault or it is a bug of the sy
You may catch a RuntimeException at the MediaRecorder.stop() method.
Example:
MediaRecorder mRecorder = new MediaRecorder();
File mFile = new File("The output file's absolutePath");
... //config the mRecorder
mRecorder.setOutputFile(mFile.getAbsolutePath());
... //prepare() ...
mRecorder.start();
try {
mRecorder.stop();
} catch(RuntimeException e) {
mFile.delete(); //you must delete the outputfile when the recorder stop failed.
} finally {
mRecorder.release();
mRecorder = null;
}