0
I’m putting together a project to learn and I can’t find a solution for a timer, let’s say that time has already been selected 10 minutes and the user wants to change to 5 minutes when clicking 5 min should cancel the old time and start the new but I can’t implement it, follows the code :
if (TIMER != null) {
TIMER.cancel();
display.setText("00:00");
} else if (TIMER == null) {
TIMER = new CountDownTimer(300000, 1000) {
public void onTick(long millisUntilFinished) {
display.setText("Tempo restante: " + millisUntilFinished / 1000);
}
public void onFinish() {
display.setText("00:00");
pausarMusica();
}
}.start();
}
So, I thought well as I was not even falling in the second if and the code runs from top to bottom I simply removed the If and left the rest of the code out, it worked! thank you!
– Juliano Souza