如何以编程方式禁用解锁屏幕
- 当用户离开定义的 WiFi 区域时,我需要锁定 Android 手机
- 我需要防止用户在定义的 WiFi 区域之外时解锁手机
- 我需要在用户返回 WiFi 区域时解锁手机
我想列表项 1 和 3 可以通过编程完成。
可以做第二项nd吗?
- I need to lock the Android phone when the user leaves a defined WiFi area
- I need to prevent the user from unlocking the phone when he/she is out side the defined WiFi area
- 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
可以使用以下方法完成锁定:如何锁定 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
。幸运的是,出于明显的安全原因,不支持此操作。
欢迎您创建自己的主屏幕,该主屏幕在定义区域内部/外部时提供不同的行为,并使用它来代替尝试阻止手机解锁。但是,欢迎用户通过将设备启动到安全模式并卸载您的应用程序来删除该主屏幕。
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.
我过去做过类似的事情,但现在没有代码,所以在这方面无法提供帮助。我所做的是将应用程序实现为汽车坞站,除非禁用汽车坞站模式,否则它将覆盖主页按钮。我希望这会有所帮助,对于代码谷歌它你肯定能找到资源
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
我想这会对你有所帮助。这仅用于
以编程方式
禁用
锁定。禁用屏幕锁定I guess this will help you out. This is just for
Disabling
the LockProgrammatically
.Disable Screen Lock公共无效 onResume() {
public void onResume() {