What I really want is to lock my phone when it's alive. Currently I press the power button to achieve that. I want to do this programmatically. Thanks to Erel who's pointed me to the solution. The lock screen feature in The Administrator library and accompanying example does exactly what I need.