I'm using WorkManager 1.0.0-alpha05
to schedule some task to run in the feature that my app may or may not be running. The job I'm going to do requires context
so how can I pass context to this?
class CompressWorker : Worker() {
override fun doWork(): Result {
//need context here
Log.e("alz", "work manager runs")
return Result.SUCCESS
}
}
And here is how I initialized the work.
val oneTimeWork = OneTimeWorkRequestBuilder<CompressWorker>()
.setInitialDelay(15, TimeUnit.MINUTES)
.build()
WorkManager.getInstance().enqueue(oneTimeWork)