【发布时间】:2019-03-09 09:21:53
【问题描述】:
Android 架构有一个新组件WorkManager。
来自example,
class CompressWorker(context : Context, params : WorkerParameters)
: Worker(context, params) {
override fun doWork(): Result {
// Do the work here--in this case, compress the stored images.
// In this example no parameters are passed; the task is
// assumed to be "compress the whole library."
myCompress()
// Indicate success or failure with your return value:
return Result.SUCCESS
// (Returning RETRY tells WorkManager to try this task again
// later; FAILURE says not to try again.)
}
}
val compressionWork = OneTimeWorkRequestBuilder<CompressWorker>().build()
如何创建一个Worker 接受构造函数或doWork 中的参数?
【问题讨论】:
标签: android kotlin android-architecture-components android-workmanager