HBRecorder icon indicating copy to clipboard operation
HBRecorder copied to clipboard

Android 14 compatibility

Open noobiewoobie opened this issue 1 year ago • 1 comments

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.

noobiewoobie avatar May 27 '24 07:05 noobiewoobie

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

codewithtamim avatar Jun 07 '24 15:06 codewithtamim

Fixed in 3.0.4

Apologies for taking so long to fix this.

HBiSoft avatar Aug 12 '24 09:08 HBiSoft

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))
       }

   }

noobiewoobie avatar Aug 13 '24 03:08 noobiewoobie