This is the handler which is I want to run always except the phone switch off
val handler = Handler()
val runnable: Runnable = object : Runnable {
override fun run() {
val geoPoint = GeoPoint(lat!!.toDouble(), lon!!.toDouble())
val liveUser = LiveUser(auth.uid.toString(), geoPoint, Timestamp.now())
updateLiveLocation(liveUser)
handler.postDelayed(this, 2000)
}
}
//Start
handler.postDelayed(runnable, 5000)