要將預設調整鈴聲改為調整多媒體音量,可改(選其中一種)
1.oncreate方法中加入setVolumeControlStream(AudioManager.STREAM_MUSIC);
2.改onkeydown:
keyCode == KeyEvent.KEYCODE_VOLUME_UP
keyCode == KeyEvent.KEYCODE_VOLUME_DOWN
AudioManager.adjustStreamVolume
ex:
public boolean onKeyDown(final int pKeyCode, final KeyEvent pEvent) {
if(pKeyCode ==KeyEvent.KEYCODE_VOLUME_UP){
audio.adjustStreamVolume(AudioManager.STREAM_MUSIC,
AudioManager.ADJUST_RAISE, AudioManager.FLAG_SHOW_UI);
return true;
}
else if(pKeyCode == KeyEvent.KEYCODE_VOLUME_DOWN){
audio.adjustStreamVolume(AudioManager.STREAM_MUSIC,
AudioManager.ADJUST_LOWER, AudioManager.FLAG_SHOW_UI);
return true;
}
}
沒有留言:
張貼留言