I have a background task that has to run in a fixed process. I'm currently using a JobIntentService
for this. However, I'd like to migrate to WorkManager to make use of network based task delays.
Is there any solution to this either using WorkManager or in any other API 14-28 compatible way?
New in WorkManager 2.5.0, there is a workmanager-multiprocess module to solve this problem. You can implement this with
implementation "androidx.work:work-multiprocess:$work_version"
To use this, you can register a new WorkManager.Initializer
as detailed in this page:
https://developer.android.com/topic/libraries/architecture/workmanager/advanced/custom-configuration
When you register this initializer, your configurations need to include a call to .setDefaultProcessName("com.example.app:processName")
. This will make the calls occur in the correct process. I am testing this out right now, and it seems to be working, but I'll update this post if there are any issues.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With