Enable Video Call (Android)

Last updated: 2021-10-21 10:13:29

    TUIKit 4.8.50 and later versions provide audio/video call features for one-to-one and group chats based on TRTC and support interconnection between iOS and Android platforms. It should be noted that the integration method varies depending on the version:


    • TUIKit versions 4.8.50 to 5.1.60 are integrated with the TRTC UI components and TRTC audio/video library by default. And therefore they support audio/video call related features by default.
    • TUIKit 5.4.666 and later versions are not integrated with the TRTC UI components and TRTC audio/video library by default. The related audio/video logic is moved to the TUIKitLive component.
    • TUIKit-Live and TUIKit must have consistent versions. Otherwise, the audio/video call feature will experience an exception and cannot work properly.

    Step 1: Activate the TRTC Service

    1. Log in to the IM console and click the target app card to go to the basic configuration page of the app.
    2. Click Activate under Activate Tencent Real-Time Communication (TRTC).
    3. Click Confirm in the pop-up dialog box.
      A TRTC app with the same SDKAppID as the IM app will be created in the TRTC console. You can use the same account and authentication information for IM and TRTC.

    Step 2: Configure Project Files

    You are advised to use the source code to integrate TUIKit and TUIKit-Live. In this way, you can modify the source code to meet your business needs.

    implementation project(':tuikit')
    implementation project(':tuikit-live')

    Step 3: Initialize TUIKit

    To initialize TUIKit, enter the SDKAppID generated in Step 1.

    TUIKitConfigs configs = TUIKit.getConfigs();
    TUIKit.init(this, SDKAPPID, configs);

    Step 4: Log In to TUIKit

    Call the login API provided by TUIKit to log in to IM. For more information on how to generate UserSig, see How to Generate Usersig.

    TUIKit.login(userID, userSig, new IUIKitCallBack() {
    public void onSuccess(Object data) {
        // Login succeeded
    public void onError(String module, final int code, final String desc) {
        // Login failed

    Step 5: Initiate an Audio/Video call

    When you tap Video or Voice on the chat UI, TUIKit automatically displays the call invitation UI and sends a call request to the peer.

    Step 6: Answer an Audio/Video call

    • When an online user receives a call invitation with the app running in the foreground, TUIKit automatically displays the call receiving UI, where the user can answer or reject the call.
    • When an offline user receives a call invitation, offline push is required if the app call UI needs to be woken up. For more information about offline push, see Step 7.

    Step 7: Offline Push

    To implement offline push for audio/video calls, follow these steps:

    1. Configure offline push for the app. For more information, see Offline Push Configuration.
    2. Upgrade TUIKit to 4.9.1 or later.
    3. Use TUIKit to initiate a call invitation. An offline push message will be generated by default. For more information about the message generation logic, see the sendOnlineMessageWithOfflinePushInfo method in the TRTCCallingImpl.java class.
    4. After the peer receives the offline push message, refer to the redirect method in the OfflineMessageDispatcher.java class to wake up the call UI.


    1. What should I be aware of if I have created the TRTC and IM SDKAppIDs and want to integrate the IM SDK and TRTC SDK at the same time?

    If you have created the TRTC and IM SDKAppIDs, you cannot use the same account or authentication information for these two apps. You need to generate a UserSig corresponding to the TRTC SDKAppID to perform authentication. For more information on how to generate UserSig, see How to Generate Usersig.
    After obtaining the TRTC SDKAppID and UserSig, you need to replace the corresponding values in the TRTCAVCallImpl source code.

    private void enterTRTCRoom() {
     TRTCCloudDef.TRTCParams TRTCParams = new TRTCCloudDef.TRTCParams(mSdkAppId, mCurUserId, mCurUserSig, mCurRoomID, "", "");

    2. How long is the default call invitation timeout duration? How can I modify the default timeout duration?

    The default call invitation timeout duration is 30s. You can modify the TIME_OUT_COUNT field in TRTCAVCallImpl to customize the timeout duration.

    3. Will an invitee receive a call invitation if the invitee goes offline and then online within the call invitation timeout duration?

    • If the call invitation is initiated in a one-to-one chat, the invitee can receive the call invitation.
    • If the call invitation is initiated in a group chat, the invitee cannot receive the call invitation.