I'm looking for a way to launch the native android lock screen from my application. I've looked around and found code about KeyGuardLock and KeyGuardMa开发者_如何学JAVAnager but I believe that only locks the keyboard from working.
REF: http://smartandroidians.blogspot.com/2010/03/enabling-and-disabling-lock-screen-in.html
Use DevicePolicyManager to lock screen..
here is how to do it : http://developer.android.com/reference/android/app/admin/DevicePolicyManager.html
To unlock..
keyGuard = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
mLock = keyGuard.newKeyguardLock("Your_App");
mLock.disableKeyguard();
To Wake the screen up..
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();
精彩评论