4

how can I programmatically set the system volume for voice call when using a bluetooth earpiece?

Using this:

mAudioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL, myVolume, 0);

when a call (using the Earpice) is in progress it doesn't change anything.

I searched a lot before posting, but can't find any hint on how to do it.

Thanks in advance.

BrainCrash
  • 11,793
  • 3
  • 28
  • 36

2 Answers2

13

I also got in same problem and found out that, Android is using int 6 for bluetooth volume and not documented.

Just use 6 instead of AudioManager.STREAM_VOICE_CALL and try, It should work

Mehul Shah
  • 351
  • 3
  • 7
  • awesome hint, frustrating that this is not documented. while it works, I have one problem with this: the volume control (the one that the system shows when you change the volume using volume up/down hardwre keys on the phone) isn't shown - any way to fix this? – stefan.at.wpf Dec 02 '12 at 11:48
  • by the way, how did you find that out? you checked the source code? which source file exactly is it? thanks :-) – stefan.at.wpf Dec 02 '12 at 11:49
  • and here is how to show the volume control: http://stackoverflow.com/questions/3581722/trigger-system-volume-bar?rq=1 :-) – stefan.at.wpf Dec 02 '12 at 11:52
  • @stefan.at.wpf I checked logs for CS call and found it. Logs are printing those values :) – Mehul Shah Jun 19 '14 at 18:21
  • You are late with your reply :P No, seriously, thanks for it, even after that long time! – stefan.at.wpf Jun 19 '14 at 19:57
  • @stefan.at.wpf not a frequent SO user :) – Mehul Shah Jun 19 '14 at 19:59
0

This will work.

mAudioManager.setStreamVolume(6, value, 0 /* flags, 0 = no flags */);
Shree
  • 18,997
  • 28
  • 86
  • 133