简体   繁体   English

android,以编程方式打开锁屏设置

[英]android, Open lock screen settings programmatically

I am creating an app to lock the screen if user has set any lock. 我正在创建一个应用程序来锁定屏幕,如果用户设置了任何锁定。 And if he has not set any lock , app will redirect it to lock screen in settings to let user set the lock first. 如果他没有设置任何锁定,应用程序会将其重定向到设置中的锁定屏幕,让用户先设置锁定。 I have used Device Admin permission to lock the screen and KeygaurdManager.isDeviceSecure method to check if it has been set or not . 我已使用设备管理员权限锁定屏幕和KeygaurdManager.isDeviceSecure方法以检查它是否已设置。

But i am unable to find how to redirect user to lock screen programmatically. 但我无法找到如何以编程方式将用户重定向到锁定屏幕。 Please help. 请帮忙。

Thanks in advance. 提前致谢。

Possible duplicate of this SO Post SO帖子可能重复

Have you tried doing this to navigate the user to a specific Settings Page - 您是否尝试过这样做以将用户导航到特定的设置页面 -

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

For opening the Security Settings use this - 要打开安全设置,请使用此 -

Intent intent = new Intent(Settings.ACTION_SECURITY_SETTINGS); 
startActivity(intent);

Moreover you can find here the constants for all the possible Actions that you can use in your app to redirect the user to a particular page on the Setting screen. 此外,您可以在此处找到可在应用程序中使用的所有可能操作的常量,以将用户重定向到“设置”屏幕上的特定页面。

Let me know if this is not what you were looking for. 如果这不是你想要的,请告诉我。

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

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