I need to detect when there is a volume change in the Audio channel to synchronize the volume set to SeekBar
By showing for example the dialog where you can adjust the volume
I would like to detect the change made, in order to reflect the change in real time in view.
In my layout I have a SeekBar
sbVolumeBooster = (SeekBar) findViewById(R.id.seek_bar_volume);
To get the maximum volume range and assign the top to SeekBar
sbVolumeBooster.setMax(audioManager.getStreamMaxVolume(streamType));
I intercept the change that can be made to SeekBar
to set the volume.
sbVolumeBooster.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
audioManager.setStreamVolume(streamType, progress, 0);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
What I'm missing
When you press the physical buttons to increase or decrease volume, the default Android dialog appears, it shows a bar to change the volume, because I am interested in obtaining the volume that has been left, to synchronize the value to the SeekBar
of the view of my app.