Kristian Nedrevold
09/23/2022, 5:57 PMsuspend fun Application.runJobs(jobService: JobService) {
withContext(this.coroutineContext) {
launch {
while (true) {
delay(1000)
println("hello")
}
}
}
}
simon.vergauwen
09/23/2022, 5:59 PMApplication
extends CoroutineScope
so the withContext
is not needed afaik.
That is the correct way to run background jobs that need to have same lifecycle as Application
.Kristian Nedrevold
09/23/2022, 6:01 PMKristian Nedrevold
09/23/2022, 6:04 PMsimon.vergauwen
09/23/2022, 6:05 PMKristian Nedrevold
09/23/2022, 6:10 PMayodele
09/26/2022, 7:52 AM