15Feb/110
Set which volume to control in your Android app!
If you're writing an Android application that plays sounds but doesn't constantly play sound/music then you've probably run into the same problem that I did where the phone's volume rocker changes the Ringer Volume instead of the Media Volume when pressed no sound is currently playing.
Good news! There's a one-liner that can fix this for you! The following single line sets the volume control stream so that when the volume buttons are pressed within your application it will adjust the Media Volume instead of the Ringer Volume:
this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
AudioManager contains a list of other pertinent constants if you would like the volume rocker to control something other than the Media Volume (ie: Ring, Notification, Alarm or In-Call Volume).

