These document the use of lockNow()
from an app that's admin.
https://developer.android.com/reference/android/app/admin/DevicePolicyManager.html#lockNow(int)
http://blogs.quovantis.com/android-device-administration-apis/
The basic process is:
create a
DeviceAdminReceiver
register the receiver in the manifest, and give it the
DEVICE_ADMIN_ENABLED
actiondeclare the security policies in an xml file
initialize a
DevicePolicyManager
object in youronCreate()
methodcall
DevicePolicyManager.lockNow()
And that works beautifully. However, I'd like to be able to lock the screen without making my app an administrator perhaps by calling lockNow()
as an implicit intent. Is this possible?