Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dismissing Keyguard Screen in Android

Tags:

android

I have an issue where Keyguard Screen is coming infront of incall screen.Need a way dismiss the Keyguard Screen.This is on 4.1 android version.I tried all the flags of windowmanager.layoutparams but did not succeed in dismissing the keyguard screen.

like image 351
user1237538 Avatar asked Dec 29 '25 14:12

user1237538


2 Answers

KeyguardManager km = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
keyguard = km.newKeyguardLock("MyApp");

to disable keygurd

public void unlockPhone() {
    keyguard.disableKeyguard();
}

and dont forget to re enable it

public void lockPhone() {
    keyguard.reenableKeyguard();
}

dont forget to use DISABLE_KEYGUARD permissionin.

like image 59
stinepike Avatar answered Dec 31 '25 06:12

stinepike


This works for me on KitKat
In onCreate before setContentView and after super

KeyguardManager keyguardManager = (KeyguardManager)   getSystemService(Activity.KEYGUARD_SERVICE);
    KeyguardLock lock = keyguardManager.newKeyguardLock(KEYGUARD_SERVICE);
    lock.disableKeyguard();
like image 45
Bachalo Avatar answered Dec 31 '25 06:12

Bachalo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!