Honnoki icon indicating copy to clipboard operation
Honnoki copied to clipboard

Reminder - Foreground service launch restrictions (Android 12)

Open flamyoad opened this issue 3 years ago • 0 comments

https://developer.android.com/about/versions/12/foreground-services

Because the CoroutineWorker.setForeground() and ListenableWorker.setForegroundAsync() methods are backed by foreground services, they're subject to the same foreground service launch restrictions and exemptions. You can use the API opportunistically, but be prepared to handle an exception if the system disallows your app from starting a foreground service. For a more consistent experience, use setExpedited().

To see a complete example of how WorkManager 2.7.0 uses expedited jobs, look through the WorkManagerSample on GitHub.

flamyoad avatar Jun 03 '21 10:06 flamyoad