I wrote an android app (with system privileges and Admin permission is granted).
In my application, at first time in the device, I am setting programmatically a new pattern screen lock, then running some things and then I want to close my app and to make the pattern screen lock re-appear so the user will have to verify it before continuing to use his device.
I couldn’t find another way to do that except for locking the device + waking it immediately, so my code looks something like this:
mLockPatternUtils.saveLockPattern(pattern);
mLockPatternUtils.setLockPatternEnabled(true);
mLockPatternUtilssetVisiblePatternEnabled(true);
//run some things
DevicePolicyManager devicePolicyManager = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);
devicePolicyManager.lockNow();
WakeLock w = powerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "TAG");
w.acquire();
But it doesn’t seem to work! The pattern screen lock is not showing. My guess is that setting the pattern when none was previously set is causing it – I just don’t know how to solve it.
By the way - doing this after a screen lock existing in the device – works fine...
Any advise??
Thanx!