我正在尝试在 viewModel 中使用 Work manager 来在服务器上上传文件,那么我该如何注入 WorkManager?
我试过这个https://developer.android.com/training/dependency-injection/hilt-jetpack
但它似乎未完成HiltWorkerFactory
且未找到
@HiltAndroidApp
class App : Application(), Configuration.Provider {
@Inject
lateinit var workerFactory: HiltWorkerFactory
override fun getWorkManagerConfiguration() = Configuration.Builder()
.setWorkerFactory(workerFactory)
.build()
}