1
I wish that when a button was clicked, 10 seconds would be added to my timer, but I couldn’t find a way to add value to Countdowntimer, here’s my code.
private void contagemRegressiva(){
new CountDownTimer(31000, 1000) {
public void onTick(long millisUntilFinished) {
tv_tempo.setText("Tempo restante: " + millisUntilFinished / 1000);
}
public void onFinish() {
tv_tempo.setText("Tempo esgotado");
}
}.start();
Countdowntimer does not have this feature. See this reply where I used/created a class similar to Countdowntimer with this possibility.
– ramaral
Very interesting your answer, but is there a simpler way to solve this problem?
– user60051
I don’t know if it’s simpler but there is. I can’t now, but I’ll put an answer later.
– ramaral
Okay, I’ll wait, thank you very much.
– user60051
What I had thought was to cancel the current Countdowntimer and create another one with the remaining time plus 10 seconds. I will not answer because when thinking about the implementation I found that it is very "ugly". Note that the answer I mentioned does not need, for this case, to use the Countdownbehavior class. The use of the Countdown class is identical to that of Countdowntimer. The difference is that instead of implementing the abstract methods you have to implement a Countdownlistener.
– ramaral
Managed to solve?
– ramaral