I have been trying to lock the device through program. But I can't find the solution still. I want to lock android froyo2.2 through program. I have tried keyguardmanager and DeviceAdminManager.
My app is to remote lock the device. When message is received with some code words to lock then it locks the phone. I have found many Api_demo program as solution but I can't extract lock code alone from that and find solution.
In order to solve this task you can take a look to NoKeyGuard source code and more precisely to a NoKeyGuard Service class and KeyguardLockWrapper class.
To unlock the device write the code in the event where you use to unlock:
The activity class should be the inner class and the outer class should extend
DeviceAdminReceiver
The activity class should be inner class and the outter class should extend DeviceAdminReceiver
To lock the device write the code in the event where you use to lock
If DeviceAdmin is enabled then the phone will be locked. To enable the device admin, the DevicePolicyManager intent is called and it should be enabled by the user.