Use keyguardManager, and put right permission in AndroidManifest
Initialize
KeyguardManager keyguardManager = (KeyguardManager)getSystemService(Activity.KEYGUARD_SERVICE);To invoke the function
final KeyguardLock lock = keyguardManager.newKeyguardLock(KEYGUARD_SERVICE);
lock.disableKeyguard();
or
lock.reenableKeyguard();
in AndroidManifest
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"></uses-permission>
沒有留言:
張貼留言