Is there a way to get/set media volume? I have tried the following:
AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
int currentVolume = audio.getStreamVolume(AudioManager.STREAM_RING);
but it returns the ringtone volume.
You can set your activity to use a specific volume. In your activity, use one of the following:
The following code will set the media stream volume to max:
Instead of
AudioManager.STREAM_RING
you shoul useAudioManager.STREAM_MUSIC
This question has already discussed here.To set volume to 0
To set volume to full
the volume can be adjusted by changing the index value between 0 and 20
If you happen to have a volume bar that you want to adjust –similar to what you see on iPhone's iPod app– here's how.