我有应用程序与计时器。当我按下电源按钮时,我的应用进入睡眠模式并停止计时。我应该怎么做计时器继续工作。下面我非常简单的代码计时器。Android应用不能在睡眠模式下工作
Thread t = new Thread(){
@Override
public void run() {
while (!isInterrupted()){
try {
Thread.sleep(1000);
i++;
Log.e("pokaz "," i "+i);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
};
看看这个:http://stackoverflow.com/questions/10725711/how-to-do-not-let-thread-stop-theme-self-when-in-standby-mode – 476rick