question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Routing call audio through the bluetooth headset

See original GitHub issue

Hello there,

I would like to allow users to switch between different audio output sources (handset, speaker, Bluetooth). I can get this done for handset and speaker by calling audioManager.setSpeakerphoneOn but how to do I handle the case where users want the audio to go through their Bluetooth headsets?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:21 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
kbagchiGWCcommented, May 7, 2019

@marklapasa

The SDK doesn’t provide bluetooth enabling API as part of the Voice Android SDK. However, this can be implemented in the application layer. In our test application we have adopted the AppRTC code provided by google.

https://webrtc.googlesource.com/src/+/master/examples/androidapp/src/org/appspot/apprtc/AppRTCAudioManager.java https://webrtc.googlesource.com/src/+/master/examples/androidapp/src/org/appspot/apprtc/AppRTCBluetoothManager.java

When a call starts you can add the following code to initialize AppRTCAudioManager and AppRTCBluetoothManager.

AppRTCAudioManager audioManager = AppRTCAudioManager.create(getApplicationContext());
audioManager.start(new AudioManagerEvents() {
    @Override
    public void onAudioDeviceChanged(AppRTCAudioManager.AudioDevice audioDevice, Set<AppRTCAudioManager.AudioDevice> availableAudioDevices) {
        onAudioManagerDevicesChanged(audioDevice, availableAudioDevices);
    }
});

Here is the link to the code snippet in AppRTC, https://webrtc.googlesource.com/src/+/master/examples/androidapp/src/org/appspot/apprtc/CallActivity.java#583 to https://webrtc.googlesource.com/src/+/master/examples/androidapp/src/org/appspot/apprtc/CallActivity.java#595

In the manifest file, make sure to add the following permissions :

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

Try this out and let me know if this does not solve the issue.

1reaction
Salim1993commented, Aug 16, 2019

@idelgado Has Bluetooth been fixed yet for android. I’ve tried a solution above and it works, except that it except for the following scenario. If you are listening to spotify using a bluetooth device, the twilio voice will take play through bluetooth device. However the call is done, it will not give back bluetooth audio to spotify, and is stuck on call.

I’ve tried a few things to fix this issue, however I have been unable to solve this.

I can’t continue debugging a this as this taking up my time from other things, and was hoping that twilio may have already fixed the solution, since it has been a while since this ticket is created. Let me know the status of this issue on your guys end.

Please and Thank you

Read more comments on GitHub >

github_iconTop Results From Across the Web

Route and automatically answer calls on iPhone - Apple Support
Route the audio of phone or FaceTime calls to the iPhone speaker, a Bluetooth headset, or your hearing devices. iPhone can also automatically...
Read more >
How to Route iPhone Calls to Bluetooth Headset or Speaker
Open the Settings app on your iPhone. · Go to Accessibility settings. · Tap on Touch. · Next up, Select Call Audio Routing....
Read more >
What is Call Audio Routing? - TRUCE Software
Most devices have options to determine how incoming and outbound audio are processed. These settings can affect the way your phone utilizes Bluetooth...
Read more >
Why can't I answer calls through a Bluetooth device after ...
Before answering a phone call, change the audio route setting in Settings: swipe down to reveal the search field, search Call Audio Routing,...
Read more >
How to Toggle a Bluetooth Headset During a Call in Android
Tap the "Bluetooth" toggle button in the lower left corner of the in-call dialer screen. The bar below the button fills with green...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found