0

I'm searching a way to make a chronometer that every 5 seconds emits a sound. The problem is that when the device is locked the timer obviously stops (because the CPU goes in sleep mode).

My code:

final Runnable r = new Runnable() {
    public void run() {
         chronsound.start();//Emit the sound
         customHandler.postDelayed(this,5000);
    }
};

There is a way to do this WITHOUT using the WakeLock? Thank you!

JAE
  • 3
  • 4
  • use a Service - for a timer I recommend an IntentService – Zoe Jun 04 '17 at 19:57
  • Possible duplicate of [Android timer that works when device is sleeping](https://stackoverflow.com/questions/4918192/android-timer-that-works-when-device-is-sleeping) – Zoe Jun 04 '17 at 19:57
  • Thank you, but the post you linked me doesn't solve my problem. – JAE Jun 05 '17 at 20:08

0 Answers0