Ok ths is becomming annoying!
I can’t really stop the timer,only pause it…
I have a function that makes x be a new timer everytime the function is called.What I need,is to sometimes stop the timer and start allover again.The problem is that if I use cancel,it pauses it and when I call the function to make a new one,it actually continues the one that wa s paused! Please help me so I can sleep…
public void countdown(){
final TextView textic = (TextView) findViewById(R.id.textView2);
x = new CountDownTimer(30000, 1000) {
public void onTick(long millisUntilFinished) {
textic.setText("Seconds remaining: " + millisUntilFinished / 1000);
}
public void onFinish() {
textic.setText("Time expired");
idiot();
getfirstquestion();
}
};
x.start();
}
That’s the function,and the x is decleared as a global variable at the beginning.What is need is: when I press a button(even 100 times) make the current timer stop,and start a really new one(like in that function).
Just cancel the old one before you create the new one.