由网友(戏如人生)分享简介:我需要我的程序定时器。我写它,它正常工作的电脑中emulalator程序(Android的1.5 / 2.2)。不过,这并不真实的设备(安卓1.5)上运行。我究竟做错了什么?TimerTask的任务=新的TimerTask(){公共无效的run(){如果(条件){myFunc的();} 其他 {this.cancel(...
我需要我的程序定时器。我写它,它正常工作的电脑中emulalator程序(Android的1.5 / 2.2)。不过,这并不真实的设备(安卓1.5)上运行。我究竟做错了什么?
TimerTask的任务=新的TimerTask(){
公共无效的run(){
如果(条件){
myFunc的();
} 其他 {
this.cancel();
}
}
};
定时器定时=新的Timer();
timer.schedule(任务,500,85);
解决方案
您需要取消()计时器不定时工作。
I need a timer for my program. I have written it and it works fine on PC in emulalator program (Android 1.5/2.2). But it doesn't work on the real device (Android 1.5). What am I doing wrong?
TimerTask task = new TimerTask() {
public void run() {
if (condition) {
myFunc();
} else {
this.cancel();
}
}
};
Timer timer = new Timer();
timer.schedule(task, 500, 85);
解决方案
You need to cancel() timer not the timer task.
相关推荐
最新文章