调整音量

mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
public boolean onKeyUp(int keyCode, KeyEvent event) {
		switch (keyCode) {
		case KeyEvent.KEYCODE_DPAD_LEFT:
			mAudioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC,
					AudioManager.ADJUST_LOWER, AudioManager.FLAG_SHOW_UI);// 调低声音
				 break;

		case KeyEvent.KEYCODE_DPAD_RIGHT:
			mAudioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC,
					AudioManager.ADJUST_RAISE, AudioManager.FLAG_SHOW_UI);//调高
			break;
		}
		return super.onKeyUp(keyCode, event);
	}

你可能感兴趣的:(调整音量)