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,621
  • 4
  • 25
  • 38
softwaresupply
  • 1,778
  • 3
  • 18
  • 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
  • 111
  • 1
  • 7
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – Rajesh Mar 27 '15 at 10:14