Skip to content
Advertisement

Can’t record with mediarecord when screen is locked. Tried WakeLock but no result

It is a ForegroundService where the OnCreate function is as follows:

JavaScript

And the startRecording() method is as follows:

JavaScript

The exception is thrown when i turn off the device, the stacktrace i get is:

JavaScript

What i want is that the recordingTask keeps running even after the device is locked. I don’t care about battery usage at this point. I know it is a pretty heavy thread. I just want it to work for now. Can someone point me in the right direction? I searched all over the web but without results.

Advertisement

Answer

I found the solution! The problem was in my manifest file I didn’t know that I had to add android:foregroundServiceType="microphone" to the service tag.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement