Hi,
Thanks for replies.
I could manage to catch the power button(not intercept), and that would be enough for our test. I use BroadcastReceiver, to hook on the power press event.
In addition, I add these flags to my Activity in order to prevent the screen from being locked when the power button is pressed:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);//prevent application from being locked
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); //I am not sure it works.
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);//turns the screen on
The last too, help me to keep the screen on(with a slight unwanted things that I describe).
The problem is that when the user press the power button, the screen turns off for about 1 second and the turns on automatically again.
Is there anyway I can prevent the screen off when user presses the power button? In that case, I can handle power press event like any other event.
(I am developing for a Nexus S, if Droid version is matter!)
Regards, specially to Dianne,