启动Android Native Lock屏幕

时间:2010-07-06 17:53:13

标签: android screen locking lockscreen

我正在寻找一种从我的应用程序启动本机android锁屏的方法。我环顾四周,找到了关于KeyGuardLock和KeyGuardManager的代码,但我相信只会阻止键盘工作。

参考:http://smartandroidians.blogspot.com/2010/03/enabling-and-disabling-lock-screen-in.html

1 个答案:

答案 0 :(得分:0)

使用DevicePolicyManager锁定屏幕..

以下是如何操作:http://developer.android.com/reference/android/app/admin/DevicePolicyManager.html

要解锁..

    keyGuard = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
        mLock = keyGuard.newKeyguardLock("Your_App");
        mLock.disableKeyguard();

唤醒屏幕..

        PowerManager pm = (PowerManager) getApplicationContext()
                .getSystemService(Context.POWER_SERVICE);
        WakeLock wakeLock = pm
                .newWakeLock(
                        (PowerManager.SCREEN_BRIGHT_WAKE_LOCK
                                | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP),
                        "TAG");
        wakeLock.acquire();