Default How to link main activity page with the power button???

Guys we r developing a phone lock....& one of the feature of the lock system is that if a wrong password is typed then the photo of the user will be captured without he/her knowing that his/her photo is captured.
Now our problem is that we aren't able to connect our app with the power button, ie, when we press the power button..the page which asks the user to enter the password. Also please tell me about the broadcast receiver & service as we have just began learning about android.
Thank you