Code example for KeyguardManager.KeyguardLock

Methods: disableKeyguard

0
        if (sWakeLock != null) {
            sWakeLock.release();
        } 
        KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
        keyguardLock = keyguardManager.newKeyguardLock("TAG");
        keyguardLock.disableKeyguard();
 
        PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
 
        sWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.FULL_WAKE_LOCK |
                                   PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, TAG);
        sWakeLock.acquire();
    } 
 
    /** 
     * Release this after you have done the work needed. Enables device lock and releases WakeLock. So if screen was 
     * locked and black before acquiring then after releasing we will return to that state. 
     */ 
    public static void release() { 
        Log.v(TAG, "Releasing wake lock");
        if (sWakeLock != null) {