简体   繁体   中英

Stop Sound when Hold key is pressed

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?

由于它解决了,Ovveride结束呼叫和电源禁止出于安全原因,我overrided“的onPause”(活动)和它的作品好,再次感谢

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM