Android 下面三个按键添加声音

来源:互联网 发布:工业设计学什么软件 编辑:程序博客网 时间:2024/05/01 18:55

在PhoneWindowManager类里找到 interceptKeyBeforeDispatching方法 在里面添加这段代码就可以了

if(down&&keyCode == KeyEvent.KEYCODE_BACK){
   final AudioManager am = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
   am.playSoundEffect(AudioManager.FX_KEY_CLICK);
   }

原创粉丝点击