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:
- Start OneTimeWorkRequest and specify to restart this method periodically in this method while the application is running in the background.
- Run PeriodicWorkRequest with a minimum allowed interval of 15 minutes. In this method, run the JobIntentService method, which runs for up to about 10 minutes, but the method may not run or may be destroyed by the system before it is complete.
I'm worried about:
- potential memory leaks;
- potential problems with WorkManager or JobIntentService when going from foreground to background and vice versa
- the ability to use the MVVM pattern
from Best way get GPS Location in background for Android API level 30 and higher
No comments:
Post a Comment