I am trying to implement a CountDownTimer to post a visual text count-down until I get to 0, then send a specific message. Everything works fine until I get to 3 seconds, it calls the my done() method twice; once with 3 seconds left and once when the counter is done.
I am certain that the only time done() is called is when onFinish() in this CountDownTimer() is called. I have no clue why it is calling twice, and at consistently the same time.
My Java Code:
mainCounter = new CountDownTimer(30000, 1000){
@Override
public void onTick(long millisUntilDone){
int hours = (int) (millisUntilDone/3600000);
int mins = 0, secs = 0;
long timeLeft = millisUntilDone % 3600000;
if((int)timeLeft != 0){
mins = (int) (timeLeft/60000);
}
long timeLeftStill = timeLeft % 60000;
if((int)timeLeftStill != 0){
secs = (int) (timeLeftStill/1000);
}
((TextView)findViewById(R.id.timer_label)).setText("You have " + hours + " hours, " + mins + " mins, " + secs + " secs left");
}
@Override
public void onFinish() {
// Send Message, Out of Time
((TextView)findViewById(R.id.timer_label)).setText("MESSAGE!");
num++;
done(); //My Own Method
this.cancel();
}
}.start();
I have another counter that works perfectly, I have commented it out to ensure it doesn't affect this counter, and like I say this one works fine until I get to 3 second left.