Browse SDKs · Android
Platform
SDKsAndroidEnterprise

Handle call events

Register the centralized Android SDK listener for call invitations, participants, and media stream state transitions.

Copy

Register OnSignalingListener centrally in your application-wide call coordinator. The SDK uses these callbacks to notify you of incoming calls, acceptances, rejections, cancellations, timeouts, hang-ups, and participant entries or exits; your application updates UI states and local media connections accordingly.

SignalingManager holds at most one listener instance; registering a new listener overwrites any previously configured listener. When logging out or switching accounts, cease processing callbacks for the previous user before registering a new listener instance.

Code example

OpenIMClient.getInstance().signalingManager.setSignalingListener(
    new OnSignalingListener() {
        @Override
        public void onReceiveNewInvitation(SignalingInfo info) {
            // info contains the incoming call invitation payload.
        }

        @Override
        public void onInviteeAccepted(SignalingInfo info) {
            // info indicates the call was accepted.
        }

        @Override
        public void onInviteeRejected(SignalingInfo info) {
            // info indicates the call was rejected.
        }

        @Override
        public void onInvitationCancelled(SignalingInfo info) {
            // info indicates the invitation was cancelled.
        }

        @Override
        public void onInvitationTimeout(SignalingInfo info) {
            // info indicates the invitation timed out.
        }

        @Override
        public void onInviteeAcceptedByOtherDevice(SignalingInfo info) {
            // info indicates another device accepted the call.
        }

        @Override
        public void onInviteeRejectedByOtherDevice(SignalingInfo info) {
            // info indicates another device rejected the call.
        }

        @Override
        public void onHangup(SignalingInfo info) {
            // info indicates the call has hung up.
        }

        @Override
        public void onRoomParticipantConnected(RoomCallingInfo room) {
            // room contains updated participant lists after entry.
        }

        @Override
        public void onRoomParticipantDisconnected(RoomCallingInfo room) {
            // room contains updated participant lists after exit.
        }

        @Override
        public void onStreamChange(String streamInfo) {
            // streamInfo contains media stream changes.
        }
    }
);

Callback events reference

CallbackTrigger conditionHandling guidance
onReceiveNewInvitationA new calling invitation arrives.Persist the SignalingInfo object, launch the incoming call interface, and await user action.
onInviteeAccepted, onInviteeRejectedAn invitee accepts or declines the invitation.Update the participant's status in the UI; in group calls, update that specific participant node without disrupting other members.
onInvitationCancelled, onInvitationTimeout, onHangupThe invitation was cancelled, expired, or terminated by either party.Dismiss calling screens, disconnect from media rooms, and release local hardware audio/video tracks.
onInviteeAcceptedByOtherDevice, onInviteeRejectedByOtherDeviceAnother active device logged into the same account handled the call.Terminate ringing and dismiss the response UI on this device to avoid multi-device conflicts.
onRoomParticipantConnected, onRoomParticipantDisconnectedA member enters or leaves the media room.Refresh active member lists and composite video grids in group calls.
onStreamChangeThe server broadcasts a media stream state change.Parse stream descriptors according to server protocols and adjust local track renderers dynamically.

State reconciliation and lifecycle

  • Global call identifier: Use roomID (accessible via SignalingInfo.invitation.roomID or RoomCallingInfo.roomID) to uniquely identify a call session for UI routing and lifecycle handling.
  • Participant identifier: Combine roomID:userID to merge acceptance, rejection, room presence, and stream states without cross-polluting concurrent group member updates.
  • Listener cleanup: SignalingManager retains a single listener. When logging out or resetting session components, pass null or unbind callbacks to prevent memory leaks and guard against obsolete UI dispatches.