How to stop CountDownTimer in android

You can call this.cancel() or simply cancel() inside one of its callback methods


You can assign it to a variable and then call cancel() on the variable

CountDownTimer yourCountDownTimer = new CountDownTimer(zaman, 1000) {                    
    public void onTick(long millisUntilFinished) {}

    public void onFinish() {}

    }.start();

yourCountDownTimer.cancel();

or you can call cancel() inside of your counter scope

new CountDownTimer(zaman, 1000) {                    
    public void onTick(long millisUntilFinished) {
        cancel();
    }

    public void onFinish() {}

    }.start();

Read more: https://developer.android.com/reference/android/os/CountDownTimer.html