Sha*_*hul 22
在您的应用程序中使用此代码,它适用于我:
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();
Run Code Online (Sandbox Code Playgroud)
http://developer.android.com/guide/topics/admin/device-admin.html
private static DevicePolicyManager dpm =
(DevicePolicyManager)context
.getSystemService(Context.DEVICE_POLICY_SERVICE);
private static ComponentName admin =
new ComponentName(context, DeviceAdminManager.class);
// add password policies you want
dpm.setPasswordQuality(admin, DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED);
dpm.setPasswordMinimumLength(admin, 5);
**boolean result = dpm.resetPassword("newPassword", RESET_PASSWORD_WITHOUT_ENTRY);**
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18270 次 |
| 最近记录: |