-1

我在我的应用程序中使用设备默认锁定屏幕来激活和停用屏幕锁定。在我的应用程序中,我使用了一个复选框,显示屏幕锁定是否已激活。

Intent intent = new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD);
startActivity(intent);

我在 DeviceAdminReceiver课堂上收到它的回调。

方法:onPasswordChanged onPasswordFailed onPasswordSucceeded

现在,如果用户选择无或按下这些方法都不会被调用。我无法确定屏幕是否被锁定?我用于OnActivityResult在我的活动中处理回调,它适用于后按(结果代码 0)但对所有其他选项给出相同的结果。

我发现这个链接告诉它不能在外部处理。

摘要:我想直接从我的应用程序处理屏幕锁定选项。

4

1 回答 1

0

如果我们在这种情况下设置密码质量,用户无法选择无密码选项可能会对您有所帮助。 我们可以这样做

private ComponentName mDeviceAdmin;
private DevicePolicyManager mDPM;

mDPM.setPasswordQuality(mDeviceAdmin, DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);

Intent intent = new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD);
mContext.startActivity(intent);
于 2014-08-23T06:14:00.160 回答