My application determines the speed limit by the user's location and tells the user if he has exceeded it. Starting with Android API level 30 and higher, Google has defined IntentService as deprecated and suggests using WorkManager or JobIntentService and also states that it is necessary to migrate from Firebase JobDispatcher to WorkManager. I see two ways to solve this problem:
I'm worried about:
I would prefer going with second option, it gives you more time between each rescheduling of the Worker
.
Regarding your concerns:
Worker
are put in the database and are executed independently of the application. Which means, user-visibility of the application has no effect. In your case, I presume you want to cancel your scheduled work once the user resumes the application, that being said you can assign a tag
to the Worker
and purge any scheduled or on-going once visible to the user.Worker
s isolated from the MVVM and just inject Use cases/interactors in the worker and do execute the use case/query the interactor. WorkerManager
offers fine APIs to query the Worker
status, you might need to write common ground between your previous implementation and for API >= 30. Treat the Worker
as different execution container for your use case.