diff --git a/app/release/HBRecorderDemo.apk b/app/release/HBRecorderDemo.apk index 3191518..bb5e474 100644 Binary files a/app/release/HBRecorderDemo.apk and b/app/release/HBRecorderDemo.apk differ diff --git a/hbrecorder/src/main/java/com/hbisoft/hbrecorder/Countdown.java b/hbrecorder/src/main/java/com/hbisoft/hbrecorder/Countdown.java index 41bb896..a04f89b 100644 --- a/hbrecorder/src/main/java/com/hbisoft/hbrecorder/Countdown.java +++ b/hbrecorder/src/main/java/com/hbisoft/hbrecorder/Countdown.java @@ -23,7 +23,7 @@ public Countdown(long totalTime, long interval, long delay) { public void start() { wasStarted = true; - this.scheduleAtFixedRate(task, delay, interval); + this.schedule(task, delay, interval); } public void stop() { diff --git a/hbrecorder/src/main/java/com/hbisoft/hbrecorder/ScreenRecordService.java b/hbrecorder/src/main/java/com/hbisoft/hbrecorder/ScreenRecordService.java index fdce7fb..8f364ff 100755 --- a/hbrecorder/src/main/java/com/hbisoft/hbrecorder/ScreenRecordService.java +++ b/hbrecorder/src/main/java/com/hbisoft/hbrecorder/ScreenRecordService.java @@ -471,10 +471,19 @@ private void setAudioSourceAsInt(String audioSource) { private void initMediaProjection() { mMediaProjection = ((MediaProjectionManager) Objects.requireNonNull(getSystemService(Context.MEDIA_PROJECTION_SERVICE))).getMediaProjection(mResultCode, mResultData); Handler handler = new Handler(Looper.getMainLooper()); - mMediaProjection.registerCallback(new MediaProjection.Callback() { - // Nothing - // We don't use it but register it to avoid runtime error from SDK 34+. - }, handler); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { + mMediaProjection.registerCallback(new MediaProjection.Callback() { + @Override + public void onStop() { + super.onStop(); + } + }, handler); + } else { + mMediaProjection.registerCallback(new MediaProjection.Callback() { + // Nothing + // We don't use it but register it to avoid runtime error from SDK 34+. + }, handler); + } } //Return the output file path as string @@ -568,6 +577,10 @@ private void initRecorder() throws Exception { @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) private void initVirtualDisplay() { + if (mMediaProjection == null) { + Log.d(TAG, "initVirtualDisplay: " + " Media projection is not initialized properly."); + return; + } mVirtualDisplay = mMediaProjection.createVirtualDisplay(TAG, mScreenWidth, mScreenHeight, mScreenDensity, DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR, mMediaRecorder.getSurface(), null, null); }