The correct use method would be setStreamVolume on your AudioManager . It might look like this.
AudioManager audioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE); audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, [int value], [if desired a flag]);
An example of using a flag is to receive a sound when setting up a volume so that the user can hear the result. The flag for this will be AudioManager.FLAG_PLAY_SOUND .
You can use AudioManager.FLAG_SHOW_UI if you do not want to play the sound, but display a toast with the current value. Use should get feedback. It doesnโt matter, audibly or visually.
To get the maximum allowable value for a given stream, you simply call getStreamMaxVolume() on the AudioManager and get the integer back, which represents ... well, the maximum allowable value for the volume.
Octavian Damiean Nov 14 '10 at 20:23 2010-11-14 20:23
source share