0
在我的應用我想成立時經過一定的時間後,在3G ...用戶反過來,我會關掉3G在超時撤銷超時.. 我的問題是取消計劃的計時器..我每次打電話timer.cancel()..程序引發錯誤如何設置的Android
問題的原因,當我打電話clearTimeout()方法..
Timer timer;
class RemindTask extends TimerTask {
public void run() {
//do something when time's up
log("timer","running the timertask..");//my custom log method
timer.cancel(); //Terminate the timer thread
}
}
public void setTimeout(int seconds) {
timer = new Timer();
timer.schedule(new RemindTask(), seconds*1000);
}
public void clearTimeout(){
log("timer", "cancelling the timer task");//my custom log method
timer.cancel();
timer.purge();
}
請幫我..我的Android初學者..
我已經嘗試CountdownTimer但取消()不是爲我工作..當計時器開始..我不能取消sechdule任務..我正在使用服務中的計時器.. – Nay