I would like to know if it is possible to repeat a CountDownTimer
infinitely?
I would like to make a blind test, which change the song when the timer is out & restart with an other song.
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.jeu);
int timeinminutes=1;
new CountDownTimer(timeinminutes*21000, 1000)
{
TextView jeutimer = (TextView) findViewById(R.id.jeu_timer);
public void onTick(long millisUntilFinished)
{
long scnds=0;
scnds=(millisUntilFinished/1000);
jeutimer.setText( "" + scnds);
}
public void onFinish()
{
}
}.start();
My problem is that there's no "restart" function, and I want to restart my countdown infinitely
you can restart it again-
timer =new CountDownTimer(360000,3000) {
@Override
public void onTick(long millisUntilFinished) {
//Some work
}
@Override
public void onFinish() {
timer.start(); // start it again after it finishes
}
}.start();
calling "this.start" in the onFinish() method also works just fine
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With