最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

android - What am I meant to do with ListenableWorker::getNetwork()? - Stack Overflow

programmeradmin0浏览0评论

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 via Worker.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.

发布评论

评论列表(0)

  1. 暂无评论