HBiSoft / HBRecorder

Lightweight screen recording Android library
MIT License
423 stars 141 forks source link

handle the screen recording alert #96

Closed ShizaS closed 2 years ago

ShizaS commented 2 years ago

How to handle the screen recording alert. Is there any callback for cancel or start recording so that actions can be take accordingly?

HBiSoft commented 2 years ago

I'm not sure I understand what you mean? Can you please elaborate?

HBiSoft commented 2 years ago

Closing until I get a response.

ShizaS commented 2 years ago

@HBiSoft When i call the startScreenRecording function i get a popup like this https://drive.google.com/file/d/1XOKKRd1uVO42FYMXj2rMOylT__vuiHCg/view?usp=sharing . Now everything works as expected when I press the start now but I cant seem to find a way on handling it when i press cancel

HBiSoft commented 2 years ago

You can change:

https://github.com/HBiSoft/HBRecorder/blob/29ebf6b112804285e4d3ce44e8a95c605d1c64b7/app/src/main/java/com/hbisoft/hbrecorderexample/MainActivity.java#L592-L602

To the following:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 
     if (requestCode == SCREEN_RECORD_REQUEST_CODE) { 
         if (resultCode == RESULT_OK) { 
             //Set file path or Uri depending on SDK version 
             setOutputPath(); 
             //Start screen recording 
             hbRecorder.startScreenRecording(data, resultCode, this); 
         } else {
             // Permission was not granted, it could be that the user pressed "Cancel" or the back button.
         }
     } 
 } 
ShizaS commented 2 years ago

It works. Thanks a lot for the quick response.