switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_UP:
Toast.makeText(getApplicationContext(), "testrise", Toast.LENGTH_LONG).show();
audio.adjustStreamVolume(AudioManager.USE_DEFAULT_STREAM_TYPE,
AudioManager.ADJUST_RAISE, AudioManager.FLAG_SHOW_UI);
return true;
case KeyEvent.KEYCODE_VOLUME_DOWN:
Toast.makeText(getApplicationContext(), "testlow", Toast.LENGTH_LONG).show();
audio.adjustStreamVolume(AudioManager.STREAM_RING,
AudioManager.ADJUST_LOWER, AudioManager.FLAG_SHOW_UI);
return true;
default:
return false;
这是我尝试做的代码...我成功实现了这个..控件只在设备中发出声音..在我的场景中我必须控制来自服务器的媒体..所以无法控制音量使用此代码