https://developer.android.com/reference/android/os/CountDownTimer
https://stackoverflow.com/questions/6425611/android-run-a-task-periodically
You can also do it by CountDownTimer
CountDownTimer countDownTimer;
public void usingCountDownTimer() {
countDownTimer = new CountDownTimer(Long.MAX_VALUE, 10000) {
// This is called after every 10 sec interval.
public void onTick(long millisUntilFinished) {
setUi("Using count down timer");
}
public void onFinish() {
start();
}
}.start();
}
and onPause()
@Override
protected void onPause() {
super.onPause();
try {
countDownTimer.cancel();
} catch (Exception e) {
e.printStackTrace();
}
}
https://developer.android.com/reference/java/util/Timer
https://developer.android.com/reference/java/util/Timer
https://developer.android.com/reference/java/util/TimerTask
https://qiita.com/aftercider/items/81edf35993c2df3de353
https://proandroiddev.com/lets-make-a-countdown-timer-app-using-android-compose-762cbdd16f3f