Skip to content Skip to sidebar Skip to footer

Locking An Android Phone (lock Pattern Or Similar)

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 l

Solution 1:

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

DevicePolicyManagerdpm= 
    (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.

Post a Comment for "Locking An Android Phone (lock Pattern Or Similar)"