how to call a function after delay in kotlin android
snippet in kotlin

how to call a function after delay in kotlin android

user1640

// Android 10+ Handler() is depricated
// Import
import android.os.Handler;
import android.os.Looper

val handler = Handler(Looper.getMainLooper())
handler.postDelayed({
  // do something after 1000ms
}, 1000)

handler in kotlin to delay

user2761

// Import
import android.os.Handler;

// Use
val handler = Handler()
handler.postDelayed({
     // do something after 1000ms
}, 1000)