0

In my app I disabled the visible keyguard screen with

if (mKkeyguardLock == null) {
    mKkeyguardLock = ((KeyguardManager)getSystemService("keyguard")).newKeyguardLock("tag");
}
mKkeyguardLock.disableKeyguard();

Then I reactivated the keyguard:

mKkeyguardLock.reenableKeyguard();
mKkeyguardLock = null;

This works, but the lock gets visible then immediately. But it should be enabled but inactive. Difference: The app remains visible. Only if the user presses the power button briefly, the lockscreen gets visible. Do you have any idea how to reenable but not activate the keyguard?

I also tried:

Window wind = MyActivity.this.getWindow();
if (wind != null) {
    wind.addFlags(LayoutParams.FLAG_DISMISS_KEYGUARD);
}

and reenabling

wind.addFlags(LayoutParams.FLAG_SHOW_WHEN_LOCKED);

This does not reactivate the keyguard at all. Thank you

barq
  • 3,681
  • 4
  • 26
  • 39
softwaresupply
  • 1,908
  • 3
  • 20
  • 34

1 Answers1

0

you can listen to broadcast listener when screen is on or off. then you can moderate keyguard.

link

for example you want to disable keyguard. if screen is on, do nothing , but if screen is off then disable the keyguard .

Community
  • 1
  • 1
tohid
  • 119
  • 1
  • 7