Android:屏幕的锁定和取消锁定

下载地址:http://download.csdn.net/source/3479523

(代码中还包括:通知,开机启动。。。。)


(private KeyguardLock m_keyguardLock = null;)


    //andorid2.1版本:对屏幕的解锁
    //使屏幕不能进行锁定
private void UnlockedScreen() {
AcquireWakeLock(1000 * 5);
Log.i(TAG, "---------------UnlockedScreen-------------");

if (m_keyguardLock != null) {
m_keyguardLock.disableKeyguard();
}
else {
KeyguardManager mKeyguardManager = (KeyguardManager)getSystemService(Context.KEYGUARD_SERVICE);
m_keyguardLock = mKeyguardManager.newKeyguardLock("");
}
}

//使屏幕可以进行锁定
private void LockScreen() {
AcquireWakeLock(1000 * 5);
Log.i(TAG, "---------------LockScreen-------------");


if (m_keyguardLock != null) {
m_keyguardLock.reenableKeyguard();
}
else {
KeyguardManager mKeyguardManager = (KeyguardManager)getSystemService(Context.KEYGUARD_SERVICE);
m_keyguardLock = mKeyguardManager.newKeyguardLock("");
}
}

你可能感兴趣的:(Android:屏幕的锁定和取消锁定)