Closed StefanLFS closed 6 months ago
I am also getting same error
The problem is in the MediaProjection. Here are the steps I did and it worked for me:
Remove the library in your app level build.gradle from dependencies (implementation).
Download and insert the com.hbisoft.hbrecorder package source code in your project.
Add ScreenRecordService in your project's AndroidManifest.xml from the hbrecorder AndroidManifest.xml.
Add NotificationReceiver in your AndroidManifest.xml from the hbrecorder AndroidManifest.xml.
Add icon.png in your project's drawable from the hbrecorder drawable.
Add strings from the hbrecorder to your project’s strings.
Then, write in the ScreenRecorderService:: initMediaProjection(), after the initialisation of mMediaProjection:
mMediaProjection.registerCallback(new MediaProjection.Callback() {
@Override
public void onStop() {
super.onStop();
}
}, null); //null if the callback should be invoked on the calling thread's looper.
Meanwhile, you should add the following permission in your AndoridManifest.xml:
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION"/>
Thank you.
Yes I did exactly like the above steps, and its working now.
This should be fixed in 3.0.2
. Thank you for all the contributions and apologies for the delay.
Receving the below error code on Android 14 Devices
Foreground services has been declared in the manifest.
error code = 100 E/HBRecorderOnError: java.lang.IllegalStateException: Must register a callback before starting capture, to manage resources in response to MediaProjection states