1
votes

The volume keys in my app are adjusting the ring tone rather than the media tone. But if there is a sound effect playing, they will adjust the media, but as soon as the sound effect finishes, it goes back to adjusting the media. I am assuming that if I have a music playing all the time, so the volume keys will allways adjust the media, but i want to leave the option for the user to have the music on/off, and adjust how loud the SFX are while playing.

Any help?

1

1 Answers

3
votes

You can use the setVolumeControlStream() method to define which Audio Stream the volume buttons should adjust while your app is in the foreground.

For example, to adjust media volume:

setVolumeControlStream(AudioManager.STREAM_MUSIC);