如何以编程方式锁定了an​​droid [英] how to lock the android programatically

查看:85
本文介绍了如何以编程方式锁定了an​​droid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想锁定手机,当我点击锁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.

这篇关于如何以编程方式锁定了an​​droid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆