/**
* 监听音量加减
*/
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_DOWN:
Toast.makeText(MainActivity.this, "减", Toast.LENGTH_SHORT).show();
break;
case KeyEvent.KEYCODE_VOLUME_UP:
Toast.makeText(MainActivity.this, "加", Toast.LENGTH_SHORT).show();
return true;
case KeyEvent.KEYCODE_VOLUME_MUTE:
return true;
}
return super.onKeyDown(keyCode, event);
}
原文:http://session.blog.51cto.com/8308112/1722360