Reputation: 197
How i can call my CountDownTimer in onResume()?
private fun countDownTime(timeOut: Long) {
object : CountDownTimer(timeOut, 1000) {
override fun onTick(millisUntilFinished: Long) {
actionWarning.text = "Please wait: " + millisUntilFinished / 1000
}
override fun onFinish() {
}
}.start()
}
Upvotes: 0
Views: 1017
Reputation: 3506
Seems like you need to extract your CountDownTimer
to a field:
class YourClass {
val timer = object : CountDownTimer(timeOut, 1000) {
override fun onTick(millisUntilFinished: Long) {
actionWarning.text = "Please wait: " + millisUntilFinished / 1000
}
override fun onFinish() {
}
}
private fun countDownTime(timeOut: Long) {
timer.start()
}
fun onResume() {
timer.whatever()
}
}
Upvotes: 2