Detect OS Sleep and Wake Up events in Java

前端 未结 3 414
礼貌的吻别
礼貌的吻别 2020-12-16 18:40

Is there a way for a Java program to detect when the operating system is about to go to sleep, or failing that, at least detecting a wake up?

The actual problem is t

3条回答
  •  独厮守ぢ
    2020-12-16 18:59

    You could detect the wakeup by periodically comparing the current system time to the previous system time.

    Edit: here's an example that looks like it would help you detect when the machine is going to sleep: http://www.codeguru.com/cpp/w-p/system/messagehandling/article.php/c6907

提交回复
热议问题