diff --git a/app/src/main/java/com/hbisoft/hbrecorderexample/MainActivity.java b/app/src/main/java/com/hbisoft/hbrecorderexample/MainActivity.java index 478dc00..e76d980 100644 --- a/app/src/main/java/com/hbisoft/hbrecorderexample/MainActivity.java +++ b/app/src/main/java/com/hbisoft/hbrecorderexample/MainActivity.java @@ -55,8 +55,6 @@ * * 1. Implement HBRecorderListener by calling implements HBRecorderListener * After this you have to implement the methods by pressing (Alt + Enter) -* This will create a method called HBRecorderOnComplete() -* This method will be called once the recording is done. * * 2. Declare HBRecorder * diff --git a/hbrecorder/src/main/java/com/hbisoft/hbrecorder/HBRecorder.java b/hbrecorder/src/main/java/com/hbisoft/hbrecorder/HBRecorder.java index 450ca2e..5d1c0e8 100644 --- a/hbrecorder/src/main/java/com/hbisoft/hbrecorder/HBRecorder.java +++ b/hbrecorder/src/main/java/com/hbisoft/hbrecorder/HBRecorder.java @@ -57,6 +57,7 @@ public class HBRecorder implements MyListener { private int videoBitrate = 40000000; private String outputFormat = "DEFAULT"; private int orientation; + boolean wasOnErrorCalled = false; @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) public HBRecorder(Context context, HBRecorderListener listener) { @@ -277,6 +278,7 @@ protected void onReceiveResult(int resultCode, Bundle resultData) { if (!mWasUriSet) { observer.stopWatching(); } + wasOnErrorCalled = true; hbRecorderListener.HBRecorderOnError(100, errorListener); try { Intent mservice = new Intent(context, ScreenRecordService.class); @@ -287,7 +289,10 @@ protected void onReceiveResult(int resultCode, Bundle resultData) { }else if (onComplete != null){ //OnComplete for when Uri was passed - hbRecorderListener.HBRecorderOnComplete(); + if (mWasUriSet && !wasOnErrorCalled) { + hbRecorderListener.HBRecorderOnComplete(); + } + wasOnErrorCalled = false; }else if (onStart != null){ hbRecorderListener.HBRecorderOnStart(); }