tencent cloud

Chat

Android(View)

Unduh
Mode fokus
Ukuran font
Terakhir diperbarui: 2026-07-06 11:25:23
This document describes how to quickly run the Chat Demo and try message sending features such as text, voice, and video. After the Demo is running, it appears as shown below:
Login Page
Conversation List Page
Chat Page




Prerequisites

Enable the Service

1. Log in to the Console. If you already have an application, note down its SDKAppID and SDKSecretKey, then proceed to the next section.
2. Click Create in the overview panel to start a new application.

3. In the application creation dialog, enter the Application Name and select Chat as the product.

4. Select the Deployment Region as needed.

5. After the application is created, locate the SDKAppID and SDKSecretKey in the console overview panel. You will need both to run the Demo.

Prohibited:
Keep your SDKSecretKey secure, do not disclose it!

Environment Preparation

Before you begin, make sure you meet the following requirements:
Android Studio 2022.3.1 or later.
A physical device or emulator running Android 6.0 or later.
A valid Chat application. See the "Enable the Service" section above to obtain or create one.
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.

Instructions

Get and Configure the Demo

1. Clone the TUIKit open-source project TUIKit_Android from GitHub.
The Chat View Demo is located in the repository's chat directory and depends on the atomic_x and call/tuicallkit-kt components in the repository root. The demo project already references these modules by relative path in settings.gradle.kts, so you do not need to configure dependency paths after cloning. The overall structure is as follows:
TUIKit_Android/
├── atomic_x/ # Base UI component library (required by Chat)
├── call/
│ └── tuicallkit-kt/ # Audio/video call component (required by Chat)
└── chat/
├── demo/ # Chat View Demo project (open and run this)
└── uikit/ # Chat View UI component library
2. Start Android Studio and open the chat/demo directory in the project.
3. Locate the GenerateTestUserSig.java file at chat/demo/app/src/main/java/io/trtc/tuikit/chat/demo/signature/GenerateTestUserSig.java, and set the following parameters:
SDKAPPID: Set this to the actual application SDKAppID obtained in the "Enable the Service" section above.
SECRETKEY: Set this to the actual secret key obtained above.
Forbidden:
1. In this Demo, authentication is performed by configuring SECRETKEY in client code. However, SECRETKEY can be easily extracted through reverse engineering. If the key is leaked, attackers can misuse your Tencent Cloud traffic. This method is suitable only for running the Demo locally and debugging features.
2. In a production environment, we recommend generating UserSig on your server. When your app needs a UserSig, request a dynamic UserSig from your business server for authentication. For details, see Generating UserSig on the Server.

Build and Run the Demo

Start Android Studio and open the chat/demo directory.
Description:
The first time you import the Demo project, many dependencies will be downloaded. Wait until download and synchronization are complete before running it.
The following uses an Android device as an example:
1. Connect the Android device to your computer, enable Developer Mode and USB debugging on the Android device, and select USB for file transfer if needed.
2. Set the Gradle JDK:
In Android Studio, go to Settings > Build, Execution, Deployment > Build Tools > Gradle.
Select JDK 17 from the Gradle JDK dropdown. If it is not listed, install JDK 17 first. Then run File > Sync Project with Gradle Files to verify the configuration.
3. Select the test device from Running devices at the top, then click Run to build, install, and run the Demo.

4. Open the app and enter any UserID to create and log in to a user account.

Experience Basic Features

After the Demo is running, you can try the basic features by following these steps.

Create User Accounts

First, you need to create user accounts. There are many ways to create accounts, such as registering on the client by logging in to the Demo or creating accounts in the Console. Choose either method based on your needs.
Client Registration
Console Registration
Enter a userID directly in the Demo and log in.
Steps:
1. Navigate to the Chat > Account Management page.
2. Click "Create Account" to open the account creation dialog.

3. For regular users, select "Regular Account". We recommend setting a nickname to help display users distinctly in the UI.

Note:
You need at least two users to send messages. Create at least two accounts at this step, and record their userIDs for use in later steps.

Add Contacts

After switching to the Contacts page:
1. Click the + button in the upper-right corner and select Add Friend from the submenu.

2. Enter a valid UserID to search for the user. If you already created accounts in the Console, you can obtain valid UserIDs from Console > Chat > Account Management.

3. Add the user as a contact. After the user is added successfully, the user appears in the Contacts list:


Send Messages

Tap the user in Contacts to open the chat UI and send text, voice, and image messages to the user:


FAQs

Using Emoji Packs

To respect emoji design copyrights, the Chat Demo/TUIKit project does not include large emoji image assets. 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 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 usage, contact us to submit feedback.

Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan