Original address: http://www.fengfly.com/plus/view-209437-1.html
The following two classes are used:
DeviceadminreceiverDevice Management components. This class provides a convenient action to explain the intent that is emitted by the system. Your device management application must contain a deviceadminreceiver subclass. In this program, it represents a Device manager on a mobile phone.Devicepolicymanager A class that manages a specification on a device. Most clients must declare a deviceadminreceiver that is currently enabled by a user. This Devicepolicymanager manages these specifications for one or more deviceadminreceiver instances. the Devicepolicymanager instance has a method called Locknow can lock the screen directly. But before this, you need to activate the Device Manager in your program.here is the main class lockactivityThe following is the Device Manager class Lockreceiver, which is a class inherited from the Deviceadminreceiver, you can receive activation/contact activation of the broadcast, the next step, in this program, just a simple print information.master configuration file:where Lock_screen is the permission declaration for Device Manager and needs to be defined as an XML file in the Res/xml directoryOK. Now you can also do a button lock screen. Don't go online to find all kinds of ads with the push.