Reputation: 33
Hi i have a push to talk application. My application does not continue to run when i press the power button and lock the screen. I am using wake lock with the flag PARTIAL_WAKE_LOCK. How can i provide my application to get voice messages when the user presses the power button.
Upvotes: 0
Views: 147
Reputation: 2062
You can get the event of keypress of Power button
@Override
public boolean dispatchKeyEvent(KeyEvent event)
{
if (event.getKeyCode() == KeyEvent.KEYCODE_POWER)
{
// Write your logic
return true;
}
return super.dispatchKeyEvent(event);
}
Hope this will help you..
Upvotes: 2