I created a Broadcast Receiver
Which is inside the Service Class
(Because of the Android Broadcast receiver
restrictions Broadca
From documentation: A service runs in the main thread of its hosting process; the service does not create its own thread and does not run in a separate process unless you specify otherwise. You should run any blocking operations on a separate thread within the service to avoid Application Not Responding (ANR) errors. I think that's the reason why you can not do "heavy" work within Service class. I didn't go through your code, but you can do two things:
1.) Make new thread inside service on create and do "heavy work"(don' forget to stop it). https://developer.android.com/guide/components/services
2.) extend JobIntentService class, give it a try. And then override function onHandleWork(intent), where you start "heavy" work. https://developer.android.com/reference/androidx/core/app/JobIntentService