Question

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... ;)

  • when my app is running ( let's say a simple stopwatch) the STOP button is displayed on the screen, the screen should be locked to avoid any unwanted tap or press.. the device will be placed in the user pocket, just counting... ( this is why I need the lock screen) after an elapsed time, the user will remove the device from his/her pocket the he will unlock the screen and press the STOP button..

briefly I want to do programmatically what I usually do before putting my device in my pocket... locking the screen ...

Was it helpful?

Solution

Have a look here http://developer.android.com/guide/topics/admin/device-admin.html#lock

DevicePolicyManager mDPM;
mDPM.lockNow();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top