1

I need to create an application that will change the bluetooth headset volume by pressing the volume up/down keys [on the phone]. While I yet don't know how to catch the volume up/down keys, I am currently more interested in how one can change the bluetooth headset volume programmatically?

Note: I want to have the bluetooth volume dialog one gets when using the phones volume up/down keys while making a call using bluetooth and the phones normal dialer / GSM call.

Cœur
  • 37,241
  • 25
  • 195
  • 267
stefan.at.kotlin
  • 15,347
  • 38
  • 147
  • 270
  • Just to clarify, you are referring to up/down keys on the blue tooth device, not the phone? – IAmGroot Dec 02 '12 at 10:29
  • oh sorry, no, I am referring to the volume up/down keys on the phone. – stefan.at.kotlin Dec 02 '12 at 10:29
  • The audio manager class seems to have alsorts you will be intrested in : http://developer.android.com/reference/android/media/AudioManager.html for example, `adjustVolume` and `isBluetoothScoOn` – IAmGroot Dec 02 '12 at 10:42
  • Looks promising, though I have one problem: How can I specify that I want to change the bluetooth headset volume? bluetoothsco is on (I set this and checked), but adjustvolume adjusts the normal call volume (the one for the phones front speaker). any hint on this? note that for testing purposes I actually don't have a stream / audio. – stefan.at.kotlin Dec 02 '12 at 11:15
  • here is how to change the BT volume: http://stackoverflow.com/questions/4472613/android-bluetooth-earpiece-volume only problem I have: nothing is show on the GUI / the volume control isn't shown, though the volume is changed. – stefan.at.kotlin Dec 02 '12 at 11:47
  • Assuming that blue tooth wouldnt be the "relevant stream", youd have to use the `adjustStreamVolume`. Maybe its adjusting the phone because blue tooth isnt present? But without it to test, maybe the emulator can emulate such things. – IAmGroot Dec 02 '12 at 11:50
  • I found the solution here: http://stackoverflow.com/questions/3581722/trigger-system-volume-bar?rq=1 Now I have all I need, thank you for the initial hints Doomsknight! – stefan.at.kotlin Dec 02 '12 at 11:51
  • Np. :) Combine everything you learnt into an answer, then mark it as excepted. So others can see how to do it. – IAmGroot Dec 02 '12 at 11:53

2 Answers2

1

Find the solution spread over this three threads:

Android Bluetooth Earpiece Volume

Trigger system volume bar

Android - Volume Buttons used in my application

Don't forget this permission:

    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> 

Thanks to Doomsknight for the initial hint :-)

Community
  • 1
  • 1
stefan.at.kotlin
  • 15,347
  • 38
  • 147
  • 270
  • stefan - how did you get this to work? I still can't get the ringtone that's playing on the bluetooth headset to change volume! Would you be open to a contract job to help me deliver on a very similar application? – rockit Apr 23 '13 at 01:22
  • rockit, the only trick is to use the answer from Mehul in http://stackoverflow.com/questions/4472613/android-bluetooth-earpiece-volume. Alternatively you can have a look at csipsimple http://code.google.com/p/csipsimple/, that's where it got implemented (not by myself though). good luck :-) – stefan.at.kotlin Apr 23 '13 at 13:22
0

Answered here how to increase and decrease the volume programmatically in android

and you should use

public static final int STREAM_BLUETOOTH_SCO = AudioSystem.STREAM_BLUETOOTH_SCO;

instead of STREAM_MUSIC
Vinayak
  • 6,056
  • 1
  • 32
  • 30