0

I have a problem about making lockscreen.

The developer site recommends to use one of this methods

  1. Method:

    private void setFlag(){
        getWindow().addFlags(
            WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
            WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
    }
    
  2. Method (it is deprecated)

    private void disableLock() {
        private KeyguardManager km = null;
        private KeyguardManager.KeyguardLock keyLock = null;
        if (km == null) 
            km = ((KeyguardManager) getSystemService("keyguard"));
        if (keyLock == null) 
            keyLock = km.newKeyguardLock("keyguard");
        keyLock.disableKeyguard();
    }
    

When I used 1. method, when screen turn on by power button it goes off again immediately (Editor: Tried my best to understand it, not sure I got it right).

When I used 1. and 2. method there is no problem!

I want to replace this method

keyLock = km.newKeyguardLock("keyguard");

is there any way to replace this method?

Thank you so much for you to read the post :)

WarrenFaith
  • 57,492
  • 25
  • 134
  • 150

0 Answers0