锁定Android手机(锁图案或类似) [英] Locking an android phone (lock pattern or similar)
问题描述
由于LOCK_PATTERN_ENABLED被转移到Settings.Secure在升级Froyo我的应用程序不能再锁屏...
Since LOCK_PATTERN_ENABLED was moved to Settings.Secure in Froyo my app can no longer lock the screen...
有谁知道解决方法吗?什么办法,我的应用程序可以立即锁定屏幕?不管它在自动锁闭模式或某种自定义锁屏...
Does anyone know a workaround for this? Any way that my app can instantly lock the screen? No matter if its the autolock pattern or some kind of custom lock screen...
推荐答案
这是一个有点麻烦...
This is a little cumbersome...
如果您添加 DeviceAdminReceiver
您的应用程序和用户启用它的安全设置,那么你allowd致电
If you add a DeviceAdminReceiver
to your app and the user enables it the security settings then you are allowd to call
DevicePolicyManager dpm =
(DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
dpm.lockNow();
要立即锁定装置。
如果你没有一个 DeviceAdminReceiver
在应用程序中调用 .lock()
将导致 SecurityException异常
。
If you don't have a DeviceAdminReceiver
in your app the call to .lock()
will cause a SecurityException
.
这篇关于锁定Android手机(锁图案或类似)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!