I was recently working on an Android application and found that when debugging the volume was to low. Using the volume control on the phone would only increase the ringer volume. By accident I found that if a media sound was playing then the volume controls would control the media volume,which indicated that the default action for the volume control is to adjust the ringer volume. So all I needed to do was work out how to change the default volume control action, and as it turns out it’s quite easy.
The Activity class has a public method called setVolumeControlStream which description is “Suggests an audio stream whose volume should be changed by the hardware volume controls.” Bingo that sounds the ticket. The method takes an int StreamType as input. The AudioManager class defines the different stream types.
So in the onCreate method for your activity add something like this:
this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
Really the article is very helpful for those who are unaware by this,that hows the sound volume can be control and now the users can easily control the volume of the android application app.
thats all well and good, it works….but when that line in there it causes my app to crash when i exit it