Browse SDKs · Android
Platform
SDKsAndroidEnterprise

Start a single call

Initiate a direct audio or video call and acquire room credentials using signalingInvite().

Copy

Initiate a direct audio or video call. The OpenIM Android SDK handles signaling negotiation and room state synchronization; once room credentials are returned, connect to your real-time audio/video media engine.

Code example

SignalingInvitationInfo invitation = new SignalingInvitationInfo();
invitation.setInviterUserID(currentUserID);
invitation.setInviteeUserIDList(Collections.singletonList(peerUserID));
invitation.setGroupID("");
invitation.setRoomID(roomID);
invitation.setTimeout(30);
invitation.setMediaType("video");
invitation.setSessionType(ConversationType.SINGLE_CHAT);
invitation.setPlatformID(Platform.ANDROID);
invitation.setCustomData("{\"source\":\"contact-card\"}");

SignalingInfo info = new SignalingInfo();
info.setInvitation(invitation);
info.setOfflinePushInfo(offlinePushInfo);

OpenIMClient.getInstance().signalingManager.signalingInvite(
    new OnBase<SignalingCertificate>() {
        @Override
        public void onSuccess(SignalingCertificate credentials) {
            // credentials provides roomID, token, and liveURL to join the media room.
        }

        @Override
        public void onError(int code, String error) {
            // code and error describe the failure.
        }
    },
    info
);

Parameters

Calling method:

signalingInvite(OnBase<SignalingCertificate> callback, SignalingInfo info)

The parameters below represent public properties on Android's SignalingInfo and its nested objects. When initiating a call, populate invitation and optional offlinePushInfo; participant and top-level userID are typically populated in incoming event payloads rather than outgoing invitations.

ParameterTypeRequiredDescription
invitationSignalingInvitationInfoYesCall invitation payload.
invitation.inviterUserIDStringYesInviter user ID; pass the authenticated user ID.
invitation.inviteeUserIDListList<String>YesCallee user list; contains exactly one peer user ID in direct calls.
invitation.groupIDStringYesTarget group ID; pass an empty string "" for direct calls.
invitation.roomIDStringYesUnique room identifier used to track and merge call state.
invitation.timeoutlongYesInvitation timeout interval in seconds.
invitation.mediaTypeStringYesMedia stream type, conventionally "audio" or "video".
invitation.sessionTypeintYesSet ConversationType.SINGLE_CHAT for direct calls, or ConversationType.SUPER_GROUP_CHAT for group calls.
invitation.platformIDintYesCurrent client platform identifier; pass Platform.ANDROID.
invitation.customDataStringNoCustom business metadata string attached to the invitation.
invitation.initiateTimelongNoTimestamp when the invitation was initiated. Managed automatically by the signaling layer.
offlinePushInfoOfflinePushInfoNoPush notification payload delivered when invitees are offline.
offlinePushInfo.titleStringConditionalNotification title; required when offlinePushInfo is provided.
offlinePushInfo.descStringConditionalNotification body text; required when offlinePushInfo is provided.
offlinePushInfo.exStringConditionalExtension string attached to push payload; pass "" if not needed.
offlinePushInfo.iOSPushSoundStringConditionalSound resource for iOS push notifications; required when providing push info.
offlinePushInfo.iOSBadgeCountbooleanConditionalWhether to badge iOS app icons; required when providing push info.
participantParticipantMetaNoParticipant profile metadata; omit when sending invitations.
userIDStringNoUser ID associated with the operation; omit when sending invitations.

Return value

Upon success, credentials in onSuccess returns a SignalingCertificate object containing:

  • roomID: Unique global identifier of the call room.
  • token: Authentication token used to join the media room.
  • liveURL: Media server endpoint URL.
  • busyLineUserIDList: List of busy user IDs if the target is already engaged in another call.

State changes after the call

  1. Callback confirmation: The onSuccess callback confirms that the signaling request succeeded and room credentials were acquired. It does not indicate that the remote peer has answered or joined media streams.
  2. Asynchronous event delivery: Both caller and callee track subsequent call events (such as answer, reject, cancel, or timeout) through OnSignalingListener. Track the overall call using roomID and monitor participant transitions using roomID:userID.
  3. Media connection: Connect to the real-time audio/video engine only after obtaining a valid token and roomID. For real-time updates regarding participant entries and stream states, see Handle call events.