I've got a Data Sync service that I'm moving to `W...
# android
a
I've got a Data Sync service that I'm moving to
WorkManager
, and it can potentially run for a long time, so I launch it with
setExpedited
and setup the
ForegroundInfo
to display a progress notification and keep it foreground. But now it fails in Android 12+ because of the new restrictions. Is there now no way to launch a long running task like this from the background? i.e. schedule a job once a week to do a data sync and have it run foreground?
😶 3
j
I'm also curious about that, because it does seem so...
I think the expedited work should be able to run from the background on android 12+, but i don't think there is a way to schedule a recurring long-running job
a
ya, from what I'm reading that appears to be the case.
I wonder if a background & non-expedited Worker could enqueue an expedited Worker :P
j
I doubt it, but it's worth a try 🙂
oh, no, i already tried that. You cannot schedule expedited job while in the background
a
One (not great) option might be to post a notification from the background that tells the user some work needs to be done. When the user taps that notification, we launch the foreground Worker. As per the docs, if the foreground job is started from a user interaction on a Notification, it will be allowed