I'm working on writing a metronome app, using haptic feedback triggered by a timer to provide the pulses. Since normally the app pauses when the screen goes off, and as a result the timer stops, I'm trying to keep the screen on using a power lock. I've provided the power permission, and have this line of code when the metronome is started:
device_power_request_lock(POWER_LOCK_DISPLAY_DIM,0);
However, the display isn't staying on. It's not returning an error. It does cause the app to run in the background now, so the timer keeps triggering, but the timer loses accuracy while the display state is changing. What am I missing to actually keep the display on and dimmed?