Skip to main content
Version: 3.x.x

External Call Detection Events - Android

VideoSDK provides external call detection events that notify you when a participant is on another call while in a room. These events help track call states and handle UI changes accordingly.

onExternalCallRinging​

  • Triggered when an incoming phone call starts ringing on the device.
  • callType is always CallType.INCOMING. Android reports no ringing for a call you place.

onExternalCallAnswered​

  • Triggered when a phone call starts on the device: the participant answers an incoming call or places an outgoing call.
  • callType is CallType.INCOMING after onExternalCallRinging, otherwise CallType.OUTGOING.

onExternalCallRejected​

  • Triggered when a ringing call ends without being answered. Android can't tell a declined call from a missed one, so both arrive here.
  • callType is always CallType.INCOMING.

onExternalCallHangup​

  • Triggered when an answered or placed call ends on the device.
  • callType is the same value that onExternalCallAnswered reported.

Override these methods in a RoomEventListener and register the listener with room.addEventListener(). They are delivered to the most recently joined room.

For example, suppose a room is running with Alice and Bob. If Alice receives a call, only Alice will receive the onExternalCallRinging event.

The SDK only reports these events. It does not mute, pause or leave the room on its own, so handle that in your app if you need to.

note

These events need the READ_PHONE_STATE permission. Declare it in AndroidManifest.xml and request it at runtime. Without it, the events never fire.

AndroidManifest.xml
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

Example​

private val roomEventListener: RoomEventListener = object : RoomEventListener() {
// ...
override fun onExternalCallRinging(callType: CallType) {
Log.d("#VideoSDK", "onExternalCallRinging: $callType")
}

override fun onExternalCallAnswered(callType: CallType) {
Log.d("#VideoSDK", "onExternalCallAnswered: $callType")
}

override fun onExternalCallRejected(callType: CallType) {
Log.d("#VideoSDK", "onExternalCallRejected: $callType")
}

override fun onExternalCallHangup(callType: CallType) {
Log.d("#VideoSDK", "onExternalCallHangup: $callType")
}
}

override fun onCreate(savedInstanceState: Bundle?) {
// ...

// Add listener to room
room!!.addEventListener(roomEventListener)
}

API Reference​

The API references for all the methods and events utilized in this guide are provided below.

Got a Question? Ask us on discord