0
我正在使用倒數計時器執行重複任務。我想確定我在做什麼是有效的,因爲我不確定倒數計時器對象是否在超時時被破壞。如果我調用取消方法,同樣的問題也適用。這裏是我的代碼:合法使用倒數計時器嗎?
public class MyCount extends CountDownTimer
{
public MyCount(long millisInFuture, long countDownInterval)
{
super(millisInFuture, countDownInterval);
}
@Override
public void onFinish()
{
new myAsyncTask().execute();
this.start();
}
@Override
public void onTick(long millisUntilFinished)
{
}
}
您是否嘗試過運行此代碼?它是否按預期工作?當從countDownTimer類中調用.cancle()和.start()時,我看到問題出現。這[後](http://stackoverflow.com/questions/3138348/how-to-stop-cancel-android-countdowntimer)也看到了這個問題,以及 –
它似乎工作正常。我只關心該對象可能已被釋放,但仍在內存中,標記爲垃圾收集。 –