Using FLAG_SHOW_WHEN_LOCKED with disableKeyguard() in secured Android lock screen

后端 未结 5 1752
轻奢々
轻奢々 2021-01-30 11:33

The Context

Recently, I have been looking for reliable ways to control a secured Android Keyguard. Mainly to display a custom lock screen. I know that Google had state

5条回答
  •  庸人自扰
    2021-01-30 12:05

    I had the same problem for the click of HOME button while unlocking the device. This can be solved by reseting the password to blank (ie "") :

    DevicePolicyManager devicePolicyManager;
    ComponentName demoDeviceAdmin;
    
    
    devicePolicyManager.setPasswordQuality(demoDeviceAdmin,DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED);
    devicePolicyManager.setPasswordMinimumLength(demoDeviceAdmin, 0);
    
    devicePolicyManager.resetPassword("",DevicePolicyManager.RESET_PASSWORD_REQUIRE_ENTRY);
    

    and then disabling the keygaurd :

    this.keyGuardLock = ((KeyguardManager)getSystemService("keyguard")).newKeyguardLock("keyguard");
    keyGuardLock.disableKeyguard();
    

    Hope this solved your problem. \m/ keep coding!

提交回复
热议问题