How to increase volume in android phone code?
1 answer(s)
You need to use the AudioManager. It is the class that controls sound in Android. First, you get the audio manager from the system context. It is pretty simple. Then you will use the adjustStreamVolume()
method. This is the main part. You tell it which sound stream to change, like AudioManager.STREAM_MUSIC
for your music or videos. Then you tell it the direction, which is AudioManager.ADJUST_RAISE
to go up. You can also add a flag, like FLAG_SHOW_UI
, so the volume bar shows on the screen for the user. It works good.