It is a ForegroundService where the OnCreate function is as follows: And the startRecording() method is as follows: The exception is thrown when i turn off the device, the stacktrace i get is: 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