2

I would like to make the volume on the Android phone go all the way up while playing a sound. I am using MediaPlayer and start() if that helps.

syb0rg
  • 8,057
  • 9
  • 41
  • 81
  • 7
    That would violate the user. They set the volume at a certain value, and they probably want to keep it that way. – syb0rg Apr 20 '13 at 18:31
  • http://developer.android.com/reference/android/media/MediaPlayer.html. Check setVolume(float,float); – Raghunandan Apr 20 '13 at 18:32

2 Answers2

0

I am developing an app to detect slip&drop of a person.
When the slip or drop happens, the app needs to turn the volume all the way up while play a sound for some period of time.

Even it violates the user, i think it is appropriate in this case.

ksu
  • 882
  • 1
  • 11
  • 17
0

Kind of late, but this should do the trick:

AudioManager audioManager = (AudioManager)getSystemService(AUDIO_SERVICE);
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC), 0);

If you want to set the volume back to its original value after you're done playing your sound, have a look at this post: Android: how to play music at maximum possible volume?

Community
  • 1
  • 1
Hunter S
  • 1,293
  • 1
  • 15
  • 26