tencent cloud

Feedback

TUICalling APIs (Android)

Last updated: 2022-03-17 15:49:52

    TRTCCalling is an open-source class based on two closed-source SDKs: Tencent Cloud Real-Time Communication (TRTC) and Instant Messaging (IM). It supports one-to-one and group audio calls. For detailed instructions how to implement it, see Real-Time Audio Call (Android).

    • TRTC SDK: The TRTC SDK is used as a low-latency audio/video call component.
    • IM SDK: The IM SDK is used to send and process signaling messages.

    TUICalling API Overview

    Basic SDK APIs

    API Description
    sharedInstance Gets a singleton.
    call Sends call invitations by user ID.
    receiveAPNSCalled Answers a call.
    setCallingListener Sets the listener.
    setCallingBell Sets the ringtone (preferably shorter than 30s).
    enableMuteMode Enables/Disables the mute mode.
    enableCustomViewRoute Enables/Disables custom views.

    TUICallingListener API Overview

    Event callbacks

    API Description
    shouldShowOnCallView Callback of whether the answering view is displayed when there is an incoming call
    onCallStart Callback for starting calling. This callback is triggered for both callers and callees.
    onCallEnd Callback for ending a call. This callback is triggered for both callers and callees.
    onCallEvent Call event callback

    Type

    Call type

    Enumerated Type Description
    AUDIO Audio call
    VIDEO Video call

    Role

    Role type

    Enumerated Type Description
    CALL Caller
    CALLED Callee

    Event

    Event type

    Enumerated Type Description
    CALL_START The call started.
    CALL_SUCCEED The call was connected successfully.
    CALL_END The call ended.
    CALL_FAILED The call failed.

    Basic SDK APIs

    sharedInstance

    This API is used to get a singleton of the TUICalling component.

    public static TUICallingManager sharedInstance();
    

    call

    This API is used to send call invitations by user ID.

    void call(String[] userIDs, Type type);
    

    The parameters are as detailed below:

    Parameter Type Description
    userIDs String[] List of the user IDs of call participants
    type TUICalling.Type Call type: audio/video

    receiveAPNSCalled

    This API is used to answer a call.

    void receiveAPNSCalled(String[] userIDs, Type type);
    

    The parameters are as detailed below:

    Parameter Type Description
    userIDs String[] List of the user IDs of call participants
    type TUICalling.Type Call type: audio/video

    setCallingListener

    This API is used to set the listener.

    void setCallingListener(TUICallingListener listener);
    

    The parameters are as detailed below:

    Parameter Type Description
    listener TUICallingListener Listener of the TUIcalling component

    setCallingBell

    This API is used to set the ringtone (preferably shorter than 30s).

    void setCallingBell(String filePath);
    

    The parameters are as detailed below:

    Parameter Type Description
    filePath String Path of the ringtone file

    enableMuteMode

    This API is used to enable/disable the mute mode.

    void enableMuteMode(boolean enable);
    

    The parameters are as detailed below:

    Parameter Type Description
    enable boolean Whether to enable the mute mode

    enableCustomViewRoute

    This API is used to enable/disable custom views.
    After enabling custom views, you will receive a CallingView instance in the callback for calling/being called, and can decide how to display the view by yourself.

    Note:

    The view must be displayed full screen or in proportion to the screen size; otherwise, an error may occur.

    void enableCustomViewRoute(boolean enable);
    

    The parameters are as detailed below:

    Parameter Type Description
    enable boolean Whether to enable custom views

    TUICallingListener Callback APIs

    shouldShowOnCallView

    Callback of whether the answering view is displayed when there is an incoming call.

    boolean shouldShowOnCallView();
    

    The parameters are as detailed below:

    Parameter Type Description
    Return value boolean Whether the answering view is displayed

    onCallStart

    Callback for starting calling, which is triggered for both callers and callees.

    void onCallStart(String[] userIDs, TUICalling.Type type, TUICalling.Role role, View tuiCallingView);
    

    The parameters are as detailed below:

    Parameter Type Description
    userIDs String[] List of the user IDs of call participants
    type TUICalling.Type Call type: audio/video
    role TUICalling.Role Role type: caller/callee
    tuiCallingView View Calling view. When enableCustomViewRoute is false, view is null.

    onCallEnd

    Callback for ending a call, which is triggered for both callers and callees.

    void onCallEnd(String[] userIDs, TUICalling.Type type, TUICalling.Role role, long totalTime);
    

    The parameters are as detailed below:

    Parameter Type Description
    userIDs String[] List of the user IDs of call participants
    type TUICalling.Type Call type: audio/video
    role TUICalling.Role Role type: caller/callee
    totalTime long Call duration (s)

    onCallEvent

    Call event callback.

    void onCallEvent(TUICalling.Event event, TUICalling.Type type, TUICalling.Role role, String message);
    

    The parameters are as detailed below:

    Parameter Type Description
    event TUICalling.Event Call event type
    type TUICalling.Type Call type: audio/video
    role TUICalling.Role Role type: caller/callee
    message String Event description
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support