I'm implementing a background worker that uploads a set of files to my backend. I'm using WorkManager for this, combined with ktor to do the network requests.
Now recently I've noticed that ListenableWorker has a getNetwork()
method (transformed to just network
in Kotlin), which returns an android.Network
.
Really the only mention of this method I've found is this snippet from WorkManager's release notes for version 2.9:
Add support for
JobParameters#getNetwork()
on API 28. This is exposed viaWorker.getNetwork()
.
JobParameters#getNetwork()
links to some documentation stating the following:
Return the network that should be used to perform any network requests for this job.
My question is simply what I am supposed to do with this network. Should I be using it to do my requests instead of my ktor client? Can I hook up said client to use this network somehow? Right now I'm just injecting the client into the worker using Hilt.
Thanks.