如何以编程方式禁用解锁屏幕

发布于 2024-12-07 22:16:33 字数 181 浏览 0 评论 0原文

  1. 当用户离开定义的 WiFi 区域时,我需要锁定 Android 手机
  2. 我需要防止用户在定义的 WiFi 区域之外时解锁手机
  3. 我需要在用户返回 WiFi 区域时解锁手机

我想列表项 1 和 3 可以通过编程完成。

可以做第二项nd吗?

  1. I need to lock the Android phone when the user leaves a defined WiFi area
  2. I need to prevent the user from unlocking the phone when he/she is out side the defined WiFi area
  3. I need to unlock the phone when user is back to the WiFi area

I guess list items 1 and 3 can be done programmatically.

Is it possible to do the 2nd item?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

鯉魚旗 2024-12-14 22:16:33

可以使用以下方法完成锁定:如何锁定 Android 设备的屏幕
解锁看这里:如何在屏幕锁定时显示 Activity?

对于你的问题2,我看到2个解决方案

。如果用户解锁屏幕,则会触发一条消息:此时检查您是否在该区域,如果不在该区域,则立即再次锁定

b。创建您自己的锁屏,而您自己无法解锁

Locking can be done using this method: How to lock the screen of an android device
Unlocking look here: How to display Activity when the screen is locked?

For your problem 2, i see 2 solutions

a. If the user unlocks the screen, a message is fired: check at that moment if you are in the area and if not, instantly lock again

b. create your own locksreen with no possibility to unlock yourself

还在原地等你 2024-12-14 22:16:33

我需要防止用户在定义的 WiFi 区域之外时解锁手机

。幸运的是,出于明显的安全原因,不支持此操作。

欢迎您创建自己的主屏幕,该主屏幕在定义区域内部/外部时提供不同的行为,并使用它来代替尝试阻止手机解锁。但是,欢迎用户通过将设备启动到安全模式并卸载您的应用程序来删除该主屏幕。

I need to prevent the user from unlocking the phone when he/she is out side the defined WiFi area

Fortunately, this is not supported, for obvious security reasons.

You are welcome to create your own home screen that offers different behavior when inside/outside a defined area and use that in lieu of trying to prevent a phone from being unlocked. However, the user is welcome to remove that home screen by booting their device into safe mode and uninstalling your app.

明天过后 2024-12-14 22:16:33

我过去做过类似的事情,但现在没有代码,所以在这方面无法提供帮助。我所做的是将应用程序实现为汽车坞站,除非禁用汽车坞站模式,否则它将覆盖主页按钮。我希望这会有所帮助,对于代码谷歌它你肯定能找到资源

I had done similar thing in past but dont have the code right now so cant help in that respect. What I did is implement the app as Car Dock that will make the Home button override unless car-dock mode is dis-abled. I hope this will help, for code google it you definitely find resources

百善笑为先 2024-12-14 22:16:33

我想这会对你有所帮助。这仅用于以编程方式禁用锁定。禁用屏幕锁定

I guess this will help you out. This is just for Disabling the Lock Programmatically.Disable Screen Lock

笑饮青盏花 2024-12-14 22:16:33
private Window w;

公共无效 onResume() {

    w = this.getWindow();
    w.addFlags(LayoutParams.FLAG_DISMISS_KEYGUARD);
    w.addFlags(LayoutParams.FLAG_SHOW_WHEN_LOCKED);
    w.addFlags(LayoutParams.FLAG_TURN_SCREEN_ON);
    super.onResume();       
    tToast("onResume");
}
private Window w;

public void onResume() {

    w = this.getWindow();
    w.addFlags(LayoutParams.FLAG_DISMISS_KEYGUARD);
    w.addFlags(LayoutParams.FLAG_SHOW_WHEN_LOCKED);
    w.addFlags(LayoutParams.FLAG_TURN_SCREEN_ON);
    super.onResume();       
    tToast("onResume");
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文