I am trying to build a countdown view inside an Android App with Kotlin. The code that I currently have crashes the app while running.
PS: Integer timer
should be altered later on the application as well.
var timer: Int = 50 // Declared globally
private fun timer(){
timer_text.text = timer.toString() // Text view in UI
while (timer > 1){
Handler().postDelayed({
timer--
timer_text.text = timer.toString() // Update the Text view in UI
}, 1000)
}
}
Logcat
I/sandaru.projec: Thread[6,tid=11100,WaitingInMainSignalCatcherLoop,Thread*=0xb400007b3dcd9f50,peer=0x13280238,"Signal Catcher"]: reacting to signal 3
I/sandaru.projec:
I/sandaru.projec: Wrote stack traces to tombstoned
D/EGL_emulation: app_time_stats: avg=5.51ms min=1.98ms max=10.47ms count=60