Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android 14 compatibility #166

Closed
noobiewoobie opened this issue May 27, 2024 · 3 comments
Closed

Android 14 compatibility #166

noobiewoobie opened this issue May 27, 2024 · 3 comments

Comments

@noobiewoobie
Copy link

I have implemented our library in my app. Everything works well till android 13. But for android 14, it is unable to record with the following error.

Recording error - Code: 100, Reason: java.lang.IllegalStateException: Must register a callback before starting capture, to manage resources in response to MediaProjection states.
at android.media.projection.MediaProjection.createVirtualDisplay(MediaProjection.java:206)
at com.hbisoft.hbrecorder.ScreenRecordService.initVirtualDisplay(ScreenRecordService.java:563)
at com.hbisoft.hbrecorder.ScreenRecordService.onStartCommand(ScreenRecordService.java:273)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4821)
at android.app.ActivityThread.-$$Nest$mhandleServiceArgs(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2289)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at android.app.ActivityThread.main(ActivityThread.java:8177)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)

I copy pasted your exact implementation and still facing this error. This issue is only happening for android 14. My target sdk is same as yours 34, I have added same permissions as you , I have followed everything as you for starting the recording and still facing this issue.

CodeWithTamim added a commit to CodeWithTamim/HBRecorder that referenced this issue Jun 7, 2024
@CodeWithTamim
Copy link

Fixed issue. Check fork on my profile. Make sure to give it a start haha.

@HBiSoft
Copy link
Owner

HBiSoft commented Aug 12, 2024

Fixed in 3.0.4

Apologies for taking so long to fix this.

@noobiewoobie
Copy link
Author

I will test it. Also, here's one more issue. It's related to setting notification icon. Strangely I cannot understand the relation between setting notification small icon while setting the recorder but if I set any icon from my side then when recording is started it works fine but when you stop the recording it fails to generate a playable video file. The file generated has extension of mp4 but you cannot play it. I tried all video configurations and it happened with all of them. So I was confused about why this is happening then I tested as follows and it works fine now.

 private fun recordingSettings() {
       hbRecorder?.let {
           it.setAudioBitrate(128000)
           it.setAudioSamplingRate(44100)
           it.recordHDVideo(false)
           it.isAudioEnabled(true)
//            it.setNotificationSmallIcon(R.drawable.logo)
           it.setNotificationTitle(getString(R.string.stop_recording_notification_title))
           it.setNotificationDescription(getString(R.string.stop_recording_notification_message))
       }

   }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants