Is there a way to tell `WorkManager` to run a work...
# android
d
Is there a way to tell
WorkManager
to run a workRequest
immediately
? If not, are there better ways of performing such tasks, i.e. tasks that should be guaranteed to run, and should start immediately. Thank you!
o
Yes, when you don't specify any constraints, the work should start executing right away, because there won't be any conditions to be met.
If you need the work to not be affected by application going into background, you'll have to start a foreground service.| https://developer.android.com/topic/libraries/architecture/workmanager/advanced/long-running
Of course many manufacturers violate the ForegroundService guarantees and it will be killed regardless, but that's another issue entirely.
Even WorkManager cannot guarantee your Work requests will run - especially on API <23. Again, this is caused by manufacturers who delete your application's alarms.
d
Thanks @okarm. I will check on that.