如何以编程方式禁用屏幕锁定密码。(How to disable screen lock password programmatically.)

编程入门 行业动态 更新时间:2024-10-18 12:28:25
如何以编程方式禁用屏幕锁定密码。(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); }

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

My script creates password and locks the phone, but if I try to change password to blank, it fails.

My locking script:

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); }

So my question is, how could I change password to blank or how could I change locking pattern to "none"?

最满意答案

2分钟后我试过了,

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

它就像一个魅力。

2 minutes later I have tried,

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

And it works like a charm.

更多推荐

本文发布于:2023-08-06 05:11:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1444521.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:屏幕   密码   方式   disable   programmatically

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!