The user expects my app to switch off the screen after being used. At the moment, I achieve this with Device Administrator rights and DevicePolicyManager.lockNow()
, which works fine if the security settings are set to PIN/Pattern/FaceUnlock, etc.
However, if using Slide/None, the above command just takes the user to the homescreen (or doesn't do anything), which is understandable, since there's nothing to "lock". Is there any way to achieve turning off the screen in such a situation? My app requires SDK>=16, if that matters.
So I guess my question is: How can an app reliably switch off the screen (I'm not holding a wakelock
, I'm using the WindowManager
-flags FLAG_TURN_SCREEN_ON
in onAttachedToWindow()
).
The "flow" of my app is:
- Activity is started by an intent while the screen is off, shows above the keyguard/switches on the screen with the above-mentioned flags
- User actively dismisses my Activity, I'm calling lockNow()
and finish()
and the user expects the screen to turn off. If the user is using the none/slide lock, this doesn't work and instead the user's homescreen is shown
Thanks!