By using Hanlder we can execute a block of code with delay
// Import
import android.os.Handler;
// Use
val handler = Handler()
handler.postDelayed({
// Write your logic here which you want to execute with dely of 5000ms
}, 5000)
How to delay a block of code in Kotlin?
Suspend function 'delay' should be called only from a coroutine or another suspend function