Created
October 15, 2019 13:50
-
-
Save tkuenneth/3e4111e47f94f80381c903a371b23229 to your computer and use it in GitHub Desktop.
How to use CountDownTimer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.thomaskuenneth.playground | |
import androidx.appcompat.app.AppCompatActivity | |
import android.os.Bundle | |
import android.os.CountDownTimer | |
import android.util.Log | |
class CountDownTimerDemo : AppCompatActivity() { | |
private val tag = CountDownTimerDemo::class.simpleName | |
private val cdt = object : CountDownTimer(7000, 1000) { | |
override fun onTick(millisUntilFinished: Long) { | |
Log.d(tag, "seconds remaining: " + millisUntilFinished / 1000) | |
} | |
override fun onFinish() { | |
Log.d(tag, "done") | |
} | |
} | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
cdt.start() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment