1
我有android自動啓動倒數計時器。我需要暫停並繼續。我見過其他解決方案,但他們沒有工作。我的代碼是:暫停和恢復android倒數計時器
class Timer extends CountDownTimer
{
public Timer(long millisInFuture, long countDownInterval)
{
super(millisInFuture, countDownInterval);
timerTimedOut = false;
}
@Override
public void onFinish() {
if(timerTimedOut){
doSTH();
} else {
doSTHElse();
}
this.start();
}
@Override
public void onTick(long millisUntilFinished)
{
timerShow.setText(Long.toString(millisUntilFinished/1000));
}
public void stop(){
timerTimedOut = true;
this.cancel();
onFinish();
}
}
我該怎麼做才能暫停和恢復?
這已經[回答](http://stackoverflow.com/q/5738362/5598783)之前。 –