public final static void lockDevice()
{
try
{
if (devicePolicyManager.isAdminActive(adminComponent))
{
devicePolicyManager.lockNow();
}
}
catch (final Exception ex)
{
...
}
}
The above code does not throw any exception nor it locks the screen for motorola xoom tablets only. (Both Homeycomb and Icecream Sandwitch) The same code works perfectly on other Homeycomb and ICS tablets.
I googled, but did not get any solution. Any Ideas.....?
Possible reasons for this problem
1) I think there is some problem with receiver's meta-data in your AndroidManifest.xml
2) You haven't added the correct class(extended with DeviceAdminReceiver) to either adminComponent OR to android:name property of receiver.
After spending lot of time on this i have created the code.
Code for main Activity
Create a new class - Darclass - code
Create a folder 'xml' in 'res'. Then create my_admin.xml file in 'xml' folder. Code for my_admin.xml. Note add this receiver after
</activity>
and before</application>
Finally add the receiver given bellow to your AndroidManifest.xml
It should work on your device.