Audio stream types

There are different profiles of ringtone streams. Each one of them has it’s different volume.

Every example here is written for AudioManager.STREAM_RING stream type. However this is not the only one. The available stream types are:

Setting volume

To get the volume of specific profile, call:

AudioManager audio = (AudioManager) getActivity().getSystemService(Context.AUDIO_SERVICE);
int currentVolume = audioManager.getStreamVolume(AudioManager.STREAM_RING);

This value is very little useful, when the maximum value for the stream is not known:

AudioManager audio = (AudioManager) getActivity().getSystemService(Context.AUDIO_SERVICE);
int streamMaxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_RING);

The ratio of those two value will give a relative volume (0 < volume < 1):

float volume = ((float) currentVolume) / streamMaxVolume

Adjusting volume by one step

To make the volume for the stream higher by one step, call:

AudioManager audio = (AudioManager) getActivity().getSystemService(Context.AUDIO_SERVICE);
audio.adjustStreamVolume(AudioManager.STREAM_RING, AudioManager.ADJUST_RAISE, 0);