屏幕关闭时如何修复thread.sleep?

时间:2018-07-22 09:21:26

标签: java android

public void run(){
    setUpTTS();
    try {
        int i = (60-getSeconds())*1000;
        Thread.sleep(i);//when screen off not work.
    } catch (InterruptedException e) {
        e.printStackTrace();
    }

    while (true){
        tts.speak("Time: "+getTime(), TextToSpeech.QUEUE_FLUSH, null);

        try {
            Thread.sleep(wait);//when screen off not work.
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}

此方法在java.class extends thread

中的位置

当屏幕打开时,当屏幕关闭时,应用程序正在运行。 但在屏幕关闭(不充电)时不起作用 然后计数器将停止(Thread.sleep)

0 个答案:

没有答案