7

I've been searching through the questions but can't find a similar one.

I'm trying to set the volume of the phone while on a call from my program. I'm using Java and Eclipse. I want this to run on ICS.

The ultimate goal is to make an app that lets the user select a contact (or group of contacts) and assign a specific volume to the phone when this person calls. Not the ringer, but the incall volume.

For example, my mother-in-law barks over the phone (in person too!) and every time she calls I have to press the volume down several times. Then, another person calls and I can barely hear them.

I have searched the play store for a similar app with no luck.

TZHX
  • 5,291
  • 15
  • 47
  • 56
  • Please Check the [link][1] it help you. I am Not check it.. [1]: http://stackoverflow.com/questions/10712615/setting-the-intial-volume-to-the-phones-ring-volume – Md Abdul Gafur Oct 11 '12 at 04:35

1 Answers1

5

Try this

AudioManager audioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL, 20, 0);

In case this doesn't work for some reason (didn't try it) you might want to read these

http://developer.android.com/reference/android/app/Activity.html#setVolumeControlStream(int) http://developer.android.com/reference/android/media/AudioManager.html#STREAM_VOICE_CALL

Gubatron
  • 6,222
  • 5
  • 35
  • 37
  • This seems to not work for me , also getStreamMaxVolume always returns 5 regardless to the actual volume level. what am I missing here? – Rotem Slootzky Feb 28 '16 at 16:56
  • getStreamMaxVolume does exactly what it says - returns maximum valid value of volume for the Stream. To get current value use ```audioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL)```, and to set max volume ```audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL, getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL), 0);``` – anro Aug 30 '19 at 08:14