Skip to main content

Audio routing

Nexconn Call SDK for Android provides basic audio routing controls through NCCallEngine. The public API currently covers two areas:

  • Control the speaker with enableSpeaker(boolean) and isSpeakerphoneEnabled().
  • Listen for system audio route changes with setAudioRouteListener(INCCallAudioRouteListener).
TypeDescription
NCCallEngineCall entry point. Handles audio route control and listener registration.
INCCallAudioRouteListenerCallback for audio route events.
NCCallAudioRouteTypeCurrent route type, including SPEAKER_PHONE, EARPIECE, HEADSET, HEADSET_BLUETOOTH, and HEADSET_BLUETOOTH_SCO.

Listen for audio route changes

After you set setAudioRouteListener(...), the SDK starts handling audio route events such as headset plug and unplug actions and Bluetooth switches. If you set the listener back to null, the SDK stops this handling.

Java
NCCallEngine engine = NCCallEngine.getInstance();

engine.setAudioRouteListener(new INCCallAudioRouteListener() {
@Override
public void onRouteChanged(NCCallAudioRouteType type) {
// For example, switched to the speaker, earpiece, wired headset, or Bluetooth device
}

@Override
public void onRouteSwitchFailed(
NCCallAudioRouteType fromType,
NCCallAudioRouteType toType
) {
// Audio route switch failed
}
});

Control the speaker

enableSpeaker(boolean) is a synchronous API. A typical usage looks like this:

Java
NCCallEngine engine = NCCallEngine.getInstance();

// Turn on the speaker
engine.enableSpeaker(true);

// Read the current speaker state
boolean speakerEnabled = engine.isSpeakerphoneEnabled();

The current code comments indicate the following defaults:

  • The speaker is on by default in video calls.
  • The speaker is off by default in audio calls.

Notes

  • The current public Android API does not expose direct query methods such as hasHeadSet() or hasBluetoothA2dpConnected(). To detect device changes, use INCCallAudioRouteListener.
  • If your app only needs a simple speaker toggle, prefer enableSpeaker(boolean). Register the audio route listener only when you also need headset or Bluetooth route events.