Possible Duplicate:
Using SeekBar to Control Volume in android?
How can i set the volume using seekbar in my android application?? I want to accurate the ringer volume from my application rather to set it from phone. Any thoughts ??
Possible Duplicate:
Using SeekBar to Control Volume in android?
How can i set the volume using seekbar in my android application?? I want to accurate the ringer volume from my application rather to set it from phone. Any thoughts ??
干得好
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
volumeSeekbar.setMax(audioManager.getStreamMaxVolume(AudioManager.STREAM_RING));
volumeSeekbar.setProgress(audioManager.getStreamVolume(AudioManager.STREAM_RING));
volumeSeekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar arg0) {}
@Override
public void onStartTrackingTouch(SeekBar arg0) {}
@Override
public void onProgressChanged(SeekBar arg0, int progress, boolean arg2) {
audioManager.setStreamVolume(AudioManager.STREAM_RING, progress, 0);
}
});