Advertisement

Responsive Advertisement

CountDowner , Timer start in android Kotlin

  • Paste this code in your activity/Fragment and run this

 private val timer=object :CountDownTimer(30000,1000){

    override fun onTick(p0: Long) {
val second=p0/1000
Log.d("roshan","OTP_Timer $second")
binding.clickToResend.text=getHtmlSpanned("Resend Code in <u><font color='#EC1C24'>${second + 1} seconds</font></u>")
}

override fun onFinish() {
binding.clickToResend.setText(R.string.click_to_resend)
binding.clickToResend.isEnabled=true
}

}
fun startTimer(){
binding.clickToResend.isEnabled=false
timer.start()
}

Post a Comment

0 Comments