Reputation: 1949
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...
Upvotes: 5
Views: 2338
Reputation: 490
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
.
Upvotes: 4