How to stop this timer , any idea ?
I want to reset timer in every query but it continues. Every new query it adds new timer. How to solve this?
new CountDownTimer(zaman, 1000) { //geriye sayma
public void onTick(long millisUntilFinished) {
NumberFormat f = new DecimalFormat("00");
long hour = (millisUntilFinished / 3600000) % 24;
long min = (millisUntilFinished / 60000) % 60;
long sec = (millisUntilFinished / 1000) % 60;
cMeter.setText(f.format(hour) + ":" + f.format(min) + ":" + f.format(sec));
}
public void onFinish() {
cMeter.setText("00:00:00");
}
}.start();
you should define it as a variable
Read more: https://developer.android.com/reference/android/os/CountDownTimer.html
static CountDownTimer countDownTimer = null;
You can call
this.cancel()
or simplycancel()
inside one of its callback methods