我正在尝试在android中构建一个应用程序,在启动时会检查设备是否安全,具有任何类型的模式或引脚 我发现这个keyguardManager isDeviceSecure()的方法,如果使用PIN,模式或密码保护设备,它会返回true。
答案 0 :(得分:0)
您可以使用DevicePolicyManager进行检查:
DevicePolicyManager devicePolicyManager = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
int passwordQuality = devicePolicyManager.getPasswordQuality(//componentName of device admin here);
if (passwordQuality == DevicePolicyManager.PASSWORD_QUALITY_SOMETHING) {
// Any password/pincode/swipe is set up.
}
if (devicePolicyManager.isActivePasswordSufficient()) {
// With this you can check if the device password is sufficient (for example if password quality changes).
}
您可能需要管理员应用程序权限来执行此操作(不确定)。在此处阅读更多内容:https://developer.android.com/reference/android/app/admin/DevicePolicyManager.html
修改强>
您还可以扩展DeviceAdminReceiver,以便在用户更改其密码或密码时捕获Intent。
public class MyDeviceAdminReceiver extends DeviceAdminReceiver {
@Override
public void onPasswordChanged(Context context, Intent intent) {
// Display your dialog here if user set any type of password.
}
}