Kotlin
private val handler = Handler(Looper.getMainLooper())
var runnable = Runnable { dismissProgressDialog() }
......
handler.postDelayed(runnable, (10 * 1000).toLong())
......
//取消任务
handler.removeCallbacks(runnable)
Kotlin
private var job: Job? = null
......
job = lifecycleScope.launch {
delay(10*1000)
dismissProgressDialog()
}
......
//取消任务
job?.cancel()