关于屏保的解除与恢复

解除屏保代码:

// 去掉屏保KeyguardManager mKeyguardManager = (KeyguardManager)getSystemService(Context.KEYGUARD_SERVICE); final KeyguardLock mKeyguardLock = mKeyguardManager.newKeyguardLock(""); mKeyguardLock.disableKeyguard();

恢复屏保代码:

// 恢复屏保mKeyguardLock.reenableKeyguard();

最后要记得加入权限:

<uses-permission android:name="android.permission.DISABLE_KEYGUARD"></uses-permission><uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>

你可能感兴趣的:(关于屏保的解除与恢复)