통합
This article will introduce how to complete the integration of the
TUIRoomKit
Component in the shortest time. By following this document, you will complete the following key steps within ten minutes and ultimately obtain an audio/video conference function with a complete UI interface.
Environment preparation
Minimum compatibility with Android 4.4 (SDK API Level 19), recommended to use Android 5.0 (SDK API Level 21) and above.
Android Studio 3.5 and above (Gradle 3.5.4 and above).
Mobile devices with Android 4.4 and above.
Step 1: Activate the service
Before initiating a meeting with TUIRoomKit, you need to activate the exclusive multi-person audio and video interaction service for TUIRoomKit on the console. For specific steps, please refer to Activate Service.
Step 2: Download the TUIRoomKit component
1. Clone/download the code in Github, and then copy the timcommon and tuiroomkit subdirectories in the Android directory to the same level directory as the app in your current project.
Step 3: Project configuration
1. Find the
setting.gradle (or settings.gradle.kts)
file in the project root directory and add the following code to it. Its function is to import the tuiroomkit component into your current project.include ':timcommon'include ':tuiroomkit'
include (":timcommon") include (":tuiroomkit")
2. Find the
build.gradle (or build.gradle.kts)
file in the app directory and add the following code to it. Its function is to declare the current app's dependence on the newly added tuiroomkit component.api project(':tuiroomkit')
api(project(":tuiroomkit"))
3. Since we use the reflection feature of Java inside the SDK, we need to add some classes in the SDK to the unobfuscated list, so you need to add the following code to the proguard-rules.pro file:
-keep class com.tencent.** { *; }
4. Find the AndroidManifest.xml file in the app directory, and add tools:replace="android:allowBackup" to the application node to override the settings within the component and use your own settings.
// app/src/main/AndroidManifest.xml<application android:name=".DemoApplication" android:allowBackup="false" android:icon="@drawable/app_ic_launcher" android:label="@string/app_name" android:largeHeap="true" android:theme="@style/AppTheme" tools:replace="android:allowBackup">
Step 4: Login
Add the following code to your project. Its function is to complete the component login by calling the relevant interface in TUILogin. This step is extremely critical, because you can only use the various functions of TUIRoomKit normally after logging in, so please be patient and check whether the relevant parameters are configured correctly:
import com.tencent.qcloud.tuicore.TUILogin; import com.tencent.qcloud.tuicore.interfaces.TUICallback;import com.tencent.cloud.tuikit.roomkit.debug.GenerateTestUserSig;String userId = "denny" // Please replace with your UserIDint sdkAppId = 1400000001 // Please replace with the sdkAppId obtained in step oneString sdkSecretKey = "xxxx" // Please replace with your sdkSecretKeyString userSig = GenerateTestUserSig.genTestUserSig(sdkAppId, userId, sdkSecretKey);TUILogin.login(context,sdkAppId,userId,userSig,new TUICallback() {@Overridepublic void onSuccess() {}@Overridepublic void onError(int errorCode, String errorMessage) {}});
import com.tencent.qcloud.tuicore.TUILogin import com.tencent.qcloud.tuicore.interfaces.TUICallbackimport com.tencent.cloud.tuikit.roomkit.debug.GenerateTestUserSigval userId = "denny" // Please replace with your UserIDval sdkAppId = 1400000001 // Please replace with the sdkAppId obtained in step oneval sdkSecretKey = "xxxx" // Please replace with your sdkSecretKeyval userSig = GenerateTestUserSig.genTestUserSig(sdkAppId, userId, sdkSecretKey)TUILogin.login(this,sdkAppId,userId,userSig,object : TUICallback() {override fun onSuccess() {}override fun onError(errorCode: Int, errorMessage: String) {}})}
TUILogin.login Parameter Description: |
Here is a detailed introduction to several key parameters needed in the login function: SDKAppID:Get it in the last step of activating the service. UserID:The ID of the current user, a string type, only allowed to contain English letters (a-z and A-Z), numbers (0-9), hyphens (-) and underscores (_). UserSig:Use the SDKSecretKey obtained in step 4 of activating the service to encrypt the SDKAppID, UserID and other information to obtain the UserSig, which is an authentication ticket used by Tencent Cloud to identify whether the current user can use TRTC services. You can generate a temporarily available UserSig through the auxiliary tools in the console. Note: Development environment:If you are in the local development and debugging stage, you can use the local GenerateTestUserSig.genTestUserSig() function to generate a userSig. The SDKSecretKey in this method can be easily decompiled and reverse-engineered. Once your key is leaked, attackers can steal your Tencent Cloud traffic. production environment:If your project is to be launched, please use the method of server-side generation of UserSig. |
Step 5: Start your first conference
// Please replace "123456" with your customized conference numberConferenceDefine.StartConferenceParams params = new ConferenceDefine.StartConferenceParams("123456");Intent intent = new Intent(this, ConferenceMainActivity.class);intent.putExtra(KEY_START_CONFERENCE_PARAMS, params);startActivity(intent);
// Please replace "123456" with your customized conference numberval params = ConferenceDefine.StartConferenceParams("123456")val intent = Intent(this, ConferenceMainActivity::class.java)intent.putExtra(KEY_START_CONFERENCE_PARAMS, params);startActivity(intent)
Step 6: Join conference
// Please replace "123456" with your customized conference numberConferenceDefine.JoinConferenceParams params = new ConferenceDefine.JoinConferenceParams("123456");Intent intent = new Intent(this, ConferenceMainActivity.class);intent.putExtra(KEY_JOIN_CONFERENCE_PARAMS, params);startActivity(intent);
// Please replace "123456" with your customized conference numberval params = ConferenceDefine.JoinConferenceParams("123456")val intent = Intent(this, ConferenceMainActivity::class.java)intent.putExtra(KEY_JOIN_CONFERENCE_PARAMS, params);startActivity(intent)
Interface display
When you successfully complete steps 1 - 6, the interface will appear as follows:
Conference main interface | User list |
| |
Common problem
Suggestions and Feedback
If you have any suggestions or feedback, please contact info_rtc@tencent.com.