本文介绍了如何打开锁屏android系统?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要调出设备的锁屏,如果一个按钮被点击。我搜索了很多,知道可以通过 DevicePolicyManager 做,但不知道该怎么做。我还发现了大量的例子,但他们都没有长大的锁屏(无误差)(例如,this或)
如何使用锁定装置 DevicePolicyManager


解决方案

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 call lockNow().

这篇关于如何打开锁屏android系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 22:56