Code example for KeyguardManager.KeyguardLock

Methods: disableKeyguard, reenableKeyguard

0
     * @param context 
     */ 
    public void toggleState(Context context) {
        getState(context);
        if(lockScreen == null) {
            Toast msg = Toast.makeText(context, "Not yet initialized", Toast.LENGTH_LONG);
            msg.setGravity(Gravity.CENTER, msg.getXOffset() / 2, msg.getYOffset() / 2);
            msg.show();
        } else { 
            getLock(context);
            if (lockScreen && lock != null) {
                lock.disableKeyguard();
                lockScreen = false;
            } else if (lock != null) {
                lock.reenableKeyguard();
                lockScreen = true;
            } 
        } 
    } 
 
    /**