I've seen two other similar questions, but no answers that work.
- Control screen brightness in android using " Background Service"
- Android Development: Changing Screen Brightness in Service
I have a background service that is trying to do some custom power management, and needs to be able to independently control the screen locking (either forcing it to lock immediately or keep it from locking) and also the display state (force it to turn off, on, or dim). I'm having a hard time finding such controls. We're developing for a device, so one option is to modify Android source code, but we're trying very hard to avoid that.
I can use PowerManager.WakeLocks to passively suggest screen brightness (and so can anyone else, so it's not guaranteed). This is okay for preventing screen lock and keeping the display on.
I did see a PowerManager.goToSleep() call for forcing the lock screen - that works. But it doesn't force the display to turn off (or something else is preventing that).
Are there any Android OS API's for this? I can't find them in the online dev guide.