繁体   English   中英

如何以编程方式禁用屏幕锁定密码。

[英]How to disable screen lock password programmatically.

我的脚本创建密码并锁定手机,但如果我尝试将密码更改为
空白,它失败了。

我的锁定脚本:

DevicePolicyManager deviceManager = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);
                  ComponentName compName = new ComponentName(MessageService.this, LockAdmin.class);  

                  boolean active = deviceManager.isAdminActive(compName);  

                  if (active) { 
                      deviceManager.setPasswordQuality(compName,DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED);
                      deviceManager.setPasswordMinimumLength(compName, 5);

                      boolean result = deviceManager.resetPassword("blablabla", DevicePolicyManager.RESET_PASSWORD_REQUIRE_ENTRY);
                  }

所以我的问题是,如何将密码更改为空白或如何将锁定模式更改为“无”?

2分钟后我试过了,

deviceManager.setPasswordMinimumLength(compName, 0);
boolean result = deviceManager.resetPassword("", DevicePolicyManager.RESET_PASSWORD_REQUIRE_ENTRY);

它就像一个魅力。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM