如何以编程方式锁定了an​​droid方式、an、droid

2023-09-07 02:57:33 作者:南鸢离梦

我想锁定手机,当我点击锁button.anybody请帮​​忙用简单的codeI试图与来自API_Demos code的一部分,但它显示了一些错误。

i want to lock the phone when i click the lock button.anybody please help with simple code.i tried with part of code from API_Demos but it shows some error.

推荐答案

在code:

KeyguardManager mgr = (KeyguardManager)getSystemService(Activity.KEYGUARD_SERVICE); 
KeyguardLock lock = mgr.newKeyguardLock(KEYGUARD_SERVICE); 
lock.reenableKeyguard();

将不会锁定屏幕。它只是使键盘保护锁。当您运行与

will NOT lock the screen. It just enables the keyguard lock. When you run with

lock.disableKeyguard();

和preSS锁定按钮,在设备上也不会锁定键盘锁。 要锁定屏幕编程,你必须参阅设备管理并使用locknow()方法来锁定设备。

and press lock button on the device it will not lock the keyguard. To lock the screen programatically you have to refer to Device Admin and use locknow() method to lock the device.