Skip to content Skip to sidebar Skip to footer

How To Detect And Control The Phone Lock/unlock On Android?

I want to make that the phone ask a question(from database) when the phone is locked (locked = the keyboard is locked ) and the user want to unlock. If the answer is correct then

Solution 1:

You may want to have a look on Device Policy Manager and Device Admin tutorial. You can lock the screen by a simple sample of code like:

DevicePolicyManagerdpm= (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);  
dpm.lockNow();

For the detection, you can follow this tutorial http://chandan-tech.blogspot.fr/2010/10/handling-screen-lock-unlock-in-android.html, it's very clear.

Post a Comment for "How To Detect And Control The Phone Lock/unlock On Android?"