当我按下按钮时,我有一个关于保存音量更改的问题,不明白为什么。你能帮忙吗?我的代码如下:
private AudioManager aManager;
private SeekBar seekVolume;
private Button save;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
aManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
Button save = (Button) findViewById(R.id.save);
}
public void saveOnClickListener(View view){
int progress = 1;
int keyCode = 0;
KeyEvent keyEvent;
aManager.setStreamVolume(AudioManager.STREAM_RING, progress , AudioManager.FLAG_SHOW_UI + AudioManager.FLAG_PLAY_SOUND);
if(keyCode==KeyEvent.KEYCODE_VOLUME_DOWN || keyCode==KeyEvent.KEYCODE_VOLUME_UP){
seekVolume.setProgress(aManager.getStreamVolume(AudioManager.STREAM_RING));
}else if (keyCode==KeyEvent.KEYCODE_VOLUME_DOWN || keyCode==KeyEvent.KEYCODE_VOLUME_UP){
seekVolume.setProgress(aManager.getStreamVolume(AudioManager.STREAM_NOTIFICATION));
}
}
}
首先,我想对振铃音量进行更改,并在按下保存按钮时提交更改。多谢你们