I am creating a Screen Capturing App. Using MediaRecorder with MediaProjection API.
Getting Run-time Exception while stopping the recorder
Here is the code to stop Screen Capture
private void stop_recorder() {
if (virtualDisplay == null) {
return;
}
virtualDisplay.release();
if (mediaProjection != null) {
mediaProjection.unregisterCallback(projectionCallback);
mediaProjection.stop();
mediaProjection = null;
}
if (recorder != null) {
recorder.stop();
recorder.reset();
}
}
The Exception occur is
E/MediaRecorder: stop failed: -1007 java.lang.RuntimeException: stop failed. at android.media.MediaRecorder.stop(Native Method)
Look android.developer doc
Solution