0

I want to stop media sound when the user press hold key or power key I do this

    public boolean onKeyDown(int keyCode, KeyEvent event) {
    if(keyCode == KeyEvent.KEYCODE_ENDCALL || keyCode == KeyEvent.KEYCODE_POWER){
        pauseSound();
    }
    return super.onKeyDown(keyCode, event);
}

But this override function didn't invoke when Power or end call is pressed

Any idea?

JustMe
  • 732
  • 1
  • 11
  • 16
  • Read this [question](http://stackoverflow.com/questions/4783960/call-method-when-home-button-pressed-on-android?rq=1) and another similar [question](http://stackoverflow.com/questions/9888250/stop-the-screen-locking-when-power-button-is-pressed?rq=1) – t0mm13b Jul 13 '12 at 15:06
  • Also [here](http://stackoverflow.com/questions/7682016/android-listen-for-power-key-press?rq=1) - Next time when posting a question - search over on the right hand side to see similar but related questions before posting :) – t0mm13b Jul 13 '12 at 15:08
  • Thanks it solved, Ovveride EndCall & Power is forbidden for security reasons, I overrided "OnPause" (of activity) and it works good, Thanks again – JustMe Jul 13 '12 at 15:25

1 Answers1

0

Thanks it solved, Ovveride EndCall & Power is forbidden for security reasons, I overrided "OnPause" (of activity) and it works good, Thanks again

JustMe
  • 732
  • 1
  • 11
  • 16