如何打开锁屏android系统? [英] how to bring up lock screen in android?
问题描述
我要调出设备的锁屏,如果一个按钮被点击。我搜索了很多,知道可以通过 DevicePolicyManager
做,但不知道该怎么做。我还发现了大量的例子,但他们都没有长大的锁屏(无误差)(例如,<一个href=\"http://stackoverflow.com/questions/12723185/android-screen-lock-unlock-programatically\">this或这)
如何使用锁定装置 DevicePolicyManager
?
我也发现了很多的例子,但他们都没有长大的锁屏(无误差)(例如本或本)
块引用>这是第二个链接应该工作。它类似于我LockMeNow示例应用程序,我知道作品正如我刚刚展示了它在训练课前两天。
您需要实现
DeviceAdminReceiver
的清单条目中包含&LT;元数据&GT;
链接到策略文档说,你希望能够&LT;强制锁/方式&gt;
设备随后,的用户的需要同意这一点,进入设置>安全>设备管理员,使您的应用程序作为设备管理员。还有就是我的样品与你链接到一个无论是在code包含code,检查,看看是否应用程序是一个设备管理员,如果没有用户通向设置去实现它。
一旦做到这一点,你可以获取
DevicePolicyManager
和呼叫lockNow()
。I want to bring up the lock screen of the device if a button is clicked. I searched a lot and know that could be done by
DevicePolicyManager
but don't know how to do that. I also found lots of examples but neither of them brought up the lock screen(with no error)(e.g. this or this) how to lock device usingDevicePolicyManager
?解决方案I also found lots of examples but neither of them brought up the lock screen(with no error)(e.g. this or this)
That second link should work. It looks similar to my LockMeNow sample app, which I know works, as I just demonstrated it in a training class two days ago.
You need to implement a
DeviceAdminReceiver
whose manifest entry contains a<meta-data>
link to a policy document that says that you want the ability to<force-lock />
the device.Then, the user needs to agree to this, by going into Settings > Security > Device Administrators and enable your app as a device administrator. There is code in both my sample and the one that you linked to that contains code that checks to see if the app is a device administrator, and if not leads the user into Settings to go enable it.
Once that is done, you can obtain a
DevicePolicyManager
and calllockNow()
.这篇关于如何打开锁屏android系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!