Have a look here http://developer.android.com/guide/topics/admin/device-admin.html#lock
DevicePolicyManager mDPM;
mDPM.lockNow();
题
After reading all related posts and answers ( varying according to the OS level..) It seems that using the DevicePolicyManager is the current solution but in this case it relies on the user to enable the app with admin access.. I wonder if my requirement could not have any other solution :
here is the 'testing' scenario ( the final app will do more... ;)
briefly I want to do programmatically what I usually do before putting my device in my pocket... locking the screen ...
解决方案
Have a look here http://developer.android.com/guide/topics/admin/device-admin.html#lock
DevicePolicyManager mDPM;
mDPM.lockNow();