0
我想停止媒體的聲音,當用戶按下HOLD鍵或電源鍵 我這樣做停止聲音的時候Hold鍵被按下
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_ENDCALL || keyCode == KeyEvent.KEYCODE_POWER){
pauseSound();
}
return super.onKeyDown(keyCode, event);
}
但是,當電源或結束通話是此覆蓋功能沒有援引按
任何想法?
閱讀[問題](http://stackoverflow.com/questions/4783960/call-method-when-home-button-press-on-android?rq = 1)和另一個類似的[question](http://stackoverflow.com/questions/9888250/stop-the-screen-鎖定電源按鈕被按下?rq = 1) – t0mm13b 2012-07-13 15:06:00
也[這裏](http://stackoverflow.com/questions/7682016/android-listen-for-power-key-press?rq = 1) - 下次發佈一個問題 - 在發佈之前在右側搜索以查看類似但相關的問題:) – t0mm13b 2012-07-13 15:08:22
感謝它解決了,Ovveride EndCall&Power由於安全原因被禁止,我忽略了「OnPause」(活動),它很好用,再次感謝 – JustMe 2012-07-13 15:25:35