By the way, while “this” does not work in a SAM, it does work in your original code:
val handler = Handler()
val runnableCode = object : Runnable {
override fun run() {
// do something
handler.postDelayed(this, 2000)
}
}
handler.post(runnableCode)