How to stop the Timer in android? [closed]
CountDownTimer waitTimer; waitTimer = new CountDownTimer(60000, 300) { public void onTick(long millisUntilFinished) { //called every 300 milliseconds, which could be used to //send messages or some other action } public void onFinish() { //After 60000 milliseconds (60 sec) finish current //if you would like to execute something when time finishes } }.start();
to stop the timer early:
if(waitTimer != null) { waitTimer.cancel(); waitTimer = null; }