MWM-for-Android
MWM-for-Android copied to clipboard
Thread.sleep() is inexact, causing notifications to get stuck
Thread.sleep() is not guaranteed to wake up after the given time. It sleeps at least the amount of time given, but, depending on different factors, may not wake up for hours.
I'm mainly thinking about the notifications. Non-sticky notifications tend to stay on the screen for a bit longer than desired (ie. the configured timeout), and are impossible to dismiss, should they get stuck, making the watch unusable for some time. My timeout is set to 10 seconds, but I've had (non-sticky) notifications stay on screen for up to a minute or so.
A simple thing to try would be to get a wakelock before sleeping and releasing it again after the notification has been dismissed, but I'm not sure it will help. The Android way to solve it is to use the AlarmManager, but that may be a bit overkill for short sleeps...