import java.util.Timerimport kotlin.concurrent.schedule// 1000 = 1sval timeout = 1000Timer().schedule(timeout) { // do something on background thread launch(Dispatchers.Main) { // do something on main/ui thread }}
NOTE: The schedule
callback is on a background thread.
NOTE: Refer to Kotlin Coroutine to launch Main/UI thread
References: