如何设置屏幕锁定使用密码编程? [英] How can i set up screen lock with a password programmatically?
本文介绍了如何设置屏幕锁定使用密码编程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有一个可以帮我一个code设置密码锁定屏幕? THX
Is there any one that can help me with a code to set a password to lock the screen ? thx
推荐答案
使用这种code在你的应用程序,它为我工作:
Use this code in your App, it works for me:
DevicePolicyManager devicePolicyManager =
DevicePolicyManager.getSystemService(Context.DEVICE_POLICY_SERVICE);
ComponentName demoDeviceAdmin = new ComponentName(this, name of activity);
devicePolicyManager.setPasswordQuality(
demoDeviceAdmin,DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED);
devicePolicyManager.setPasswordMinimumLength(demoDeviceAdmin, 5);
boolean result = devicePolicyManager.resetPassword("123456",
DevicePolicyManager.RESET_PASSWORD_REQUIRE_ENTRY);
Toast.makeText(this,
"button_lock_password_device..."+result,
Toast.LENGTH_LONG).show();
这篇关于如何设置屏幕锁定使用密码编程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文