1
在我的活動之一,我有一個的TimerTask當屏幕未鎖定/關閉但似乎因爲我鎖屏儘快暫停其工作正常。我需要做什麼才能不中斷運行TimerTask的(無論畫面是否是上或關閉TimerTask的暫停時,屏幕被鎖定
預先感謝您做!
class RunnerTask extends TimerTask
{
public void run() {
runOnUiThread(new Runnable(){
@Override
public void run(){
if(intervalCounter_ < maxInterval_)
{
vibrator_.vibrate(vibrationPattern_, -1);
//System.out.println("Running... - " + new Date());
intervalCounter_++;
}
else
{
vibrator_.vibrate(vibrationPattern_, -1);
//System.out.println("Timer ended... - " + new Date());
runningTimer_.cancel();
}
}
});
}
}