I would like to know how to keep the screen permanently on from a service. Here is the scenario for the code: User plugs phone into power outlet, Broadcast receiver gets event, start a service that prevent the screen from timing out. User unplugs phone, service is killed and timeout restored.
I wanted to use wakelocks but the level that is needed is deprecated in API 13:
int SCREEN_BRIGHT_WAKE_LOCK This constant was deprecated in API level 13. Most applications should use FLAG_KEEP_SCREEN_ON instead of this type of wake lock, as it will be correctly managed by the platform as the user moves between applications and doesn't require a special permission.
FLAG_KEEP_SCREEN_ON
cannot be used from a service from what I've read.
I don't want to modify the screen timeout number since if my service is destroyed or application uninstalled, I don't want the timeout to be stuck at a high number.
Also my application cannot get any system permission so anything requiring DEVICE_POWER
permission, I can't use
Any idea? Thanks for any insight, Amish