tencent cloud

Chat

Android(View)

다운로드
포커스 모드
폰트 크기
마지막 업데이트 시간: 2026-10-30 19:45:39
TUIKit is an open-source UI component library built on the Chat SDK. It uses a data-driven, reactive architecture and is built with native Android Views (not Jetpack Compose). It provides complete UI components for the conversation list, chat, contacts, search, groups, and more, with built-in theme switching and global configuration. This document describes how to quickly integrate TUIKit and implement core features.
The TUIKit UI is shown below:
Conversation List
Chat
Audio/Video Call




Method 1: AI Integration

Run npx @tencent-rtc/trtc-agent-skills add --ide <your IDE> in the project root directory to install trtc-agent-skills into your local AI IDE to assist with TUIKit integration (<your IDE> can be replaced with cursor, codebuddy, claude, or codex, or use all to install all of them). After installation, you can give the AI requests such as "Integrate Android Chat", "Add a custom message type", or "Switch between light and dark themes". Based on your project type, the AI will guide you through code integration, API calls, UI style modification, and test data generation. For details, see AI Coding Skills.

Method 2: Manual Integration

Environment Requirements

Android Studio 2022.3.1 or later, JDK 17.
A physical device or emulator running Android 6.0 or later.
Your project must support Kotlin, because TUIKit is developed in Kotlin.
minSdk >= 23.
A valid Tencent Cloud account and Chat application. See Activate the Service to obtain the following information from the Console:
SDKAppID: The ID of the Chat application obtained from the Console. It is the unique identifier of the application.
SDKSecretKey: The application secret key.

Version Compatibility Notice:

To ensure a stable build environment, strictly follow the official compatibility requirements:
For compatibility between Gradle, Android Gradle Plugin, JDK, and Android Studio, see the Android official documentation: Release Notes.
For the mapping between Kotlin, Android Gradle Plugin, and Gradle versions, see the Kotlin official documentation: Kotlin-Gradle Plugin Compatibility.
We recommend selecting a version combination that fully matches your project requirements according to these guidelines.

Integrate and Import Components

Note:
Demo: The complete GitHub Demo works out of the box. You can run all chat and audio/video call features in 5 minutes.

Download the Source Code

Download the TUIKit Android source code from GitHub:
git clone https://github.com/Tencent-RTC/TUIKit_Android.git
Copy the chat, call, and atomic_x folders from the repository root directory to the root directory of your project. The directory structure after copying is as follows:
YourApplication/
├── app/ # Your app module
├── atomic_x/ # Base UI component library
├── call/ # Audio/video call component
│ └── tuicallkit-kt/
├── chat/ # Chat source code
│ ├── demo/ # Demo project
│ └── uikit/ # Chat UIKit component library
├── settings.gradle.kts
└── build.gradle.kts
Note:
TUIKit_Android is an open-source repository that contains multiple products. The Chat UI source code is located in the chat/ directory (chat/uikit is the UIKit component library, and chat/demo is the demo project). The base component atomic_x and the audio/video call component call/tuicallkit-kt that it depends on are located in the repository root directory. You can place the module directories anywhere in your project, as long as you set the correct relative paths in settings.gradle.kts.

Integrate Components

1. Add the corresponding modules in settings.gradle.kts. Adjust the relative paths based on where you actually place the source code:
Kotlin DSL
Groovy DSL
// settings.gradle.kts

include(":atomic_x")
project(":atomic_x").projectDir = file("${settingsDir.path}/atomic_x")

include(":uikit")
project(":uikit").projectDir = file("${settingsDir.path}/chat/uikit")

include(":tuicallkit-kt")
project(":tuicallkit-kt").projectDir = file("${settingsDir.path}/call/tuicallkit-kt")
// settings.gradle

include ':atomic_x'
project(':atomic_x').projectDir = new File(settingsDir, 'atomic_x')

include ':uikit'
project(':uikit').projectDir = new File(settingsDir, 'chat/uikit')

include ':tuicallkit-kt'
project(':tuicallkit-kt').projectDir = new File(settingsDir, 'call/tuicallkit-kt')
2. Add dependencies to the app module's build.gradle.kts:
Kotlin DSL
Groovy DSL
// app/build.gradle.kts
dependencies {
implementation(project(":atomic_x"))
implementation(project(":uikit"))
implementation(project(":tuicallkit-kt"))
}
// app/build.gradle
dependencies {
implementation project(':atomic_x')
implementation project(':uikit')
implementation project(':tuicallkit-kt')
}

Implementation Steps

After completing the integration above, follow these steps to quickly build core UIs such as the conversation list, chat, and contacts with only a few lines of code.

Step 1. Configure User Authentication

In Console > Development Tools > UserSig Tools, obtain a UserSig based on the UserID. The UserSig is used for user authentication during login.


Step 2. User Login

You must log in before using component features. Call the login API of LoginStore and pass in the sdkAppID, userID, and userSig obtained above for login authentication:
import io.trtc.tuikit.atomicxcore.api.CompletionHandler
import io.trtc.tuikit.atomicxcore.api.login.LoginStore
import com.tencent.cloud.tuikit.engine.call.TUICallEngine
import com.tencent.cloud.tuikit.engine.common.TUICommonDefine

LoginStore.shared.login(
context,
sdkAppID, // Int, obtained from the Console
userID, // String
userSig, // String, generated in the Console or on your server
object : CompletionHandler {
override fun onSuccess() {
// Login succeeded
TUICallEngine.createInstance(context).init(
sdkAppID, userID, userSig,
object : TUICommonDefine.Callback {
override fun onSuccess() {
// Initialization succeeded. You can use audio/video call features.
}
override fun onError(errCode: Int, errMsg: String) {
// Initialization failed
}
}
)
}
override fun onFailure(code: Int, desc: String) {
// Login failed. You can show an error dialog.
}
}
)
Note:
In a production environment, we recommend generating UserSig on your server. When needed, your app should request a dynamic UserSig from your business server for authentication. For details, see Generating UserSig on the Server.

Step 3. Build the Chat UI

Use ChatPageView to display and send or receive messages. Pass conversationID through setup. The conversationID format is c2c_<peer UserID> for one-to-one chats and group_<GroupID> for group chats.
import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import io.trtc.tuikit.chat.uikit.pages.ChatPageView

class ChatActivity : AppCompatActivity() {

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

// conversationID format: "c2c_<peer UserID>" for one-to-one chats, "group_<GroupID>" for group chats
val conversationID = intent.getStringExtra("conversationID") ?: return

val chatPageView = ChatPageView(this)
chatPageView.setup(conversationID = conversationID)
setContentView(chatPageView)
}

companion object {
fun start(context: Context, conversationID: String) {
context.startActivity(Intent(context, ChatActivity::class.java).apply {
putExtra("conversationID", conversationID)
})
}
}
}
Note:
The Demo project provides ChatActivity, a chat page encapsulated based on ChatPageView with a title bar, unread badges, group event handling, and more. You can reuse it directly or refer to its implementation for customization: ChatActivity.start(context, conversationID).

Step 4. Audio/Video Calls

After a successful login, initialize TUICallEngine to use audio/video call features in TUIKit components.
Note:
To use audio/video call features, see the Activate Audio/Video Service document to activate the service.
If the audio/video service is not activated, tapping the call button in TUIKit components will show an error message. Other TUIKit features are not affected.
import com.tencent.cloud.tuikit.engine.call.TUICallEngine
import com.tencent.cloud.tuikit.engine.common.TUICommonDefine

// Initialize TUICallEngine in the LoginStore login success callback in Step 2
TUICallEngine.createInstance(context).init(
sdkAppID, userID, userSig,
object : TUICommonDefine.Callback {
override fun onSuccess() {
// Initialization succeeded. You can use audio/video call features.
}

override fun onError(errCode: Int, errMsg: String) {
// Initialization failed
}
}
)

Step 5. Integrate the AI Customer Service Desk Client

To integrate the Desk customer client as well, first activate the Desk service, and then import and configure the com.tencentcloud.desk:aideskcustomer package as described in Integrating the Desk Customer Client on Android. You can then add customer service conversations to your app.
int SDKAppID = 0; // The ID of the application with AI Customer Service Desk activated
String userID = "";
String userSig = "";

// The preceding three parameters can be the same as those used to log in to Tencent Cloud Chat, or you can use a different application and user.

// User nickname. After it is set, a human agent can see it in the workbench when the user is successfully transferred to a human agent. You can write information such as the user's phone number and source into the nickname. Maximum length: 500 bytes.
// Note: After it is set, the nickname of the same userID in Chat is also updated.
// If you do not want to change it, set it to "" or null.
String nickName = "";

// User avatar. After it is set, a human agent can see it in the workbench when the user is successfully transferred to a human agent.
// Note: After it is set, the avatar of the same userID in Chat is also updated.
// If you do not want to change it, set it to "" or null.
String avatar = "";

TencentAiDeskCustomer.getInstance().initWithProfile(context, SDKAppID, userID, userSig, nickName, avatar, new AIDeskCallback() {
@Override
public void onSuccess() {
startActivity(TencentAiDeskCustomer.getInstance().getCustomerServiceChatIntent(context));
}
@Override
public void onError(int code, String desc) {}
});

AI Assistant: Knowledge Consultation and Code Integration

While integrating the Chat SDK, you can use the AI assistant through MCP to quickly get knowledge consultation, troubleshoot errors, and generate UIKit integration code. It supports platforms such as Web, Android, iOS, Flutter, and uni-app, and its answers are based on the official documentation. It is suitable for scenarios such as querying SDK APIs, UI component usage, server APIs, and Chat product configuration. Try it now and ask your first question.

FAQs

Audio/Video FAQs

What is the default timeout for a call invitation?
The default timeout for a call invitation is 30 seconds.
If an invitee goes offline and then comes back online within the invitation timeout, can they receive the invitation immediately?
For a one-to-one call invitation, an invitee who goes offline and then comes back online can receive the call invitation, and TUIKit automatically displays the call invitation UI.
For a group call invitation, after an invitee goes offline and then comes back online, the invitations from the last 30 seconds are automatically pulled, and TUIKit automatically displays the group call UI.
How do I remove the audio/video call feature?
If you do not need the audio/video call feature, remove the tuicallkit-kt dependency from settings.gradle.kts (or settings.gradle) and the build.gradle.kts (or build.gradle) file of the app module, and turn off the audio/video call switches in Step 3. Build the Chat UI, as shown in the following code:
val messageInputConfig = ChatMessageInputConfig(
isShowAudioCall = false, // Disable voice calls
isShowVideoCall = false // Disable video calls
)
val chatPageView = ChatPageView(this)
chatPageView.setup(
conversationID = conversationID,
messageInputConfig = messageInputConfig
)

Other FAQs

Using Emoji Packs
To respect copyrights, the Chat Demo/TUIKit project does not include large emoji image assets by default. Before commercial release, replace them with emoji packs designed by you or otherwise licensed to you. The default smiley emoji pack shown below is copyrighted by Tencent Cloud and can be licensed for a fee. To obtain a license, you can use it for free by upgrading to Chat Pro Plus or Enterprise Edition.




Contact Us

If you have any questions or suggestions during integration or use, contact us to submit feedback.

도움말 및 지원

문제 해결에 도움이 되었나요?

피드백