<Coroutine Job operation at the push of a button> ...
# stackoverflow
u
Coroutine Job operation at the push of a button Declaration of variables private lateinit var wayoJob: Job override val coroutineContext: CoroutineContext get() = Dispatchers.Main + wayoJob Function @InternalCoroutinesApi private fun startRepeatingJob(timeInterval: Long): Job { return CoroutineScope(Dispatchers.Default).launch { while (NonCancellable.isActive) { Log.i("API", "UPDATE") delay(timeInterval) } } } In the Start Button wayoJob = startRepeatingJob(5000L) In Button end and...