简体   繁体   English

以编程方式打开设备密码更改 android

[英]Open device password change programmatically android

How can I programmatically open the Change Password Screen under Settings -> Security -> Choose screen lock -> Password.如何以编程方式打开“设置”->“安全”->“选择屏幕锁定”->“密码”下的“更改密码”屏幕。

Right now I am using the following code and its getting me as far as Settings -> Security -> Choose screen lock, but I want to force the Password option.现在我正在使用下面的代码,它让我就设置 - >安全 - >选择屏幕锁定,但我想强制密码选项。 Not swipe or pin option.不是刷卡或固定选项。

R.id.change_phone_password:
Intent change = new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD);
startActivity(change);

I am running Android 10.我正在运行 Android 10。

You need to use the "setPasswordQuality" API of the android DevicePolicyManager.您需要使用 android DevicePolicyManager 的“setPasswordQuality”API。 You app has to be registered as a device admin app in order for it to use this API.您的应用必须注册为设备管理应用才能使用此 API。 This API will let you specify password quality as something, numeric, alphanumeric etc. You can also look at other APIs like "setPasswordMinimumLength", "setPasswordHistoryLength", "setPasswordMinimumUpperCase" for more control over what type/length of password you want your endusers to use.此 API 可让您将密码质量指定为数字、字母数字等。您还可以查看其他 API,例如“setPasswordMinimumLength”、“setPasswordHistoryLength”、“setPasswordMinimumUpperCase”,以更好地控制您希望最终用户使用的密码类型/长度利用。 All this is only possible if you app is a device admin app.只有当您的应用程序是设备管理应用程序时,这一切才有可能。

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

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