Since LOCK_PATTERN_ENABLED was moved to Settings.Secure in Froyo my app can no longer lock the screen...
Does anyone know a workaround for this? Any way that my app can instantly lock the screen? No matter if its the autolock pattern or some kind of custom lock screen...
This is a little cumbersome...
If you add a DeviceAdminReceiver
to your app and the user enables it the security settings then you are allowd to call
DevicePolicyManager dpm =
(DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
dpm.lockNow();
to lock the device immediately.
If you don't have a DeviceAdminReceiver
in your app the call to .lock()
will cause a SecurityException
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With