100% success to crash the app: Press start immediately followed by stop
Excepts always with java.lang.IllegalStateException
What is the way to prevent that?
According to its doc: note that a RuntimeException is intentionally thrown to the application if no valid audio/video data has been received when stop() is called. This happens if stop() is called immediately after start().The failure lets the application take action accordingly to clean up the output file (delete the output file, for instance), since the output file is not properly constructed when this happens.
Stupid workaround according to someone's blog:
try {
mediarecorder.setOnErrorListener(null);
mediarecorder.setOnInfoListener(null);
mediarecorder.setPreviewDisplay(null);
mediarecorder.stop();
} catch (IllegalStateException e) {
Log.i("Exception", Log.getStackTraceString(e));
}catch (RuntimeException e) {
Log.i("Exception", Log.getStackTraceString(e));
}catch (Exception e) {
Log.i("Exception", Log.getStackTraceString(e));
}
This sample has been migrated to a new location where we can accept Pull Requests (check README for more information).
As recommended by GitHub, we are closing all issues and pull requests now that this older repo will be archived.
If you still see this issue in the updated repo, please reopen the issue/PR there. Thank you!