I have a CountDownTimer in my app setup like this:
new CountDownTimer(11000, 1000) {
public void onTick(long millisUntilFinished) {
clock.setText("Seconds Remaining: " + millisUntilFinished / 1000);
secsrem = (int) millisUntilFinished / 1000;
}
public void onFinish() {
//...}
}.start();
I need to access the onFinish method in another method in my app so that when a button is pressed it will call the timers onFinish method. How would i do this?
Just store your timer in a variable:
Then you can do:
Btw, I think you should not call
onFinishyourself, it will be called by system when the time is up. If you want to cancel the timer instead use: