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.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")
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"))
-keep class com.tencent.** { *; }
// 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">
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. |
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/conference_container" android:layout_width="match_parent" android:layout_height="match_parent" />
import com.tencent.cloud.tuikit.roomkit.ConferenceError;import com.tencent.cloud.tuikit.roomkit.ConferenceMainFragment;import com.tencent.cloud.tuikit.roomkit.ConferenceObserver;public class ConferenceOwnerActivity extends AppCompatActivity {private ConferenceObserver mConferenceObserver;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_conference);ConferenceMainFragment fragment = new ConferenceMainFragment();mConferenceObserver = new ConferenceObserver() {@Overridepublic void onConferenceStarted(String conferenceId, ConferenceError error) {super.onConferenceStarted(conferenceId, error);if (error != ConferenceError.SUCCESS) {return;}FragmentManager manager = getSupportFragmentManager();FragmentTransaction transaction = manager.beginTransaction();transaction.add(R.id.conference_container, fragment);transaction.commitAllowingStateLoss();}};fragment.setConferenceObserver(mConferenceObserver);// Replace "123456" with the corresponding conference numberfragment.quickStartConference("123456");}}
import com.tencent.cloud.tuikit.roomkit.ConferenceErrorimport com.tencent.cloud.tuikit.roomkit.ConferenceMainFragmentimport com.tencent.cloud.tuikit.roomkit.ConferenceObserverclass ConferenceOwnerActivity : AppCompatActivity() {private var mConferenceObserver : ConferenceObserver? = nulloverride fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)setContentView(R.layout.activity_conference)var fragment = ConferenceMainFragment()mConferenceObserver = object: ConferenceObserver() {override fun onConferenceStarted(conferenceId: String?, error: ConferenceError?) {super.onConferenceStarted(conferenceId, error)if (error != ConferenceError.SUCCESS) {return}val fragmentManager = supportFragmentManagerval transaction = fragmentManager.beginTransaction()transaction.add(R.id.conference_container, fragment)transaction.commitAllowingStateLoss()}}fragment.setConferenceObserver(mConferenceObserver)// Replace "123456" with the corresponding conference numberfragment.quickStartConference("123456")}}
<!--app/src/main/AndroidManifest.xml --><?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"> <application ... <activity ... </activity><!-- Add the following code to register ConferenceOwnerActivity --> <activity android:name=".ConferenceOwnerActivity" /> </application> </manifest>
import android.content.Intent;import android.os.Bundle;import androidx.appcompat.app.AppCompatActivity;public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);// Jump to ConferenceOwnerActivity Intent intent = new Intent(MainActivity.this, ConferenceOwnerActivity.class); startActivity(intent); } }
import android.content.Intentimport android.os.Bundleimport androidx.appcompat.app.AppCompatActivityclass MainActivity : AppCompatActivity() {override fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)setContentView(R.layout.activity_main)// Jump to ConferenceOwnerActivityval intent = Intent(this, ConferenceOwnerActivity::class.java)startActivity(intent)}}
public class ConferenceGeneralActivity extends AppCompatActivity {private static final String TAG = "ConferenceGeneralActivity";private ConferenceObserver mConferenceObserver;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_conference);ConferenceMainFragment fragment = new ConferenceMainFragment();mConferenceObserver = new ConferenceObserver() {@Overridepublic void onConferenceJoined(String conferenceId, ConferenceError error) {super.onConferenceJoined(conferenceId, error);if (error != ConferenceError.SUCCESS) {Log.e(TAG, "Error : " + error);return;}FragmentManager manager = getSupportFragmentManager();FragmentTransaction transaction = manager.beginTransaction();transaction.add(R.id.conference_container, fragment);transaction.commitAllowingStateLoss();}};fragment.setConferenceObserver(mConferenceObserver);// Replace "123456" with the corresponding conference numberfragment.joinConference("123456");}}
class ConferenceGeneralActivity : AppCompatActivity() { private val tag: String = "ConferenceGeneralActivity" private var mConferenceObserver : ConferenceObserver? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_conference) var fragment = ConferenceMainFragment() mConferenceObserver = object: ConferenceObserver() { override fun onConferenceJoined(conferenceId: String?, error: ConferenceError?) { super.onConferenceJoined(conferenceId, error) if (error != ConferenceError.SUCCESS) { Log.e(tag, "Error : $error") return } val fragmentManager = supportFragmentManager val transaction = fragmentManager.beginTransaction() transaction.add(R.id.conference_container, fragment) transaction.commitAllowingStateLoss() } } fragment.setConferenceObserver(mConferenceObserver) // Replace "123456" with the corresponding conference number fragment.joinConference("123456") } }
<!--app/src/main/AndroidManifest.xml --><?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"> <application ... <activity ... </activity><!-- Add the following code to register ConferenceOwnerActivity --> <activity android:name=".ConferenceOwnerActivity" /><!-- Add the following code to register ConferenceGeneralActivity --><activity android:name=".ConferenceGeneralActivity" /> </application> </manifest>
import android.content.Intent;import android.os.Bundle;import androidx.appcompat.app.AppCompatActivity;public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);// Jump to ConferenceGeneralActivity Intent intent = new Intent(MainActivity.this, ConferenceGeneralActivity.class); startActivity(intent); } }
import android.content.Intentimport android.os.Bundleimport androidx.appcompat.app.AppCompatActivityclass MainActivity : AppCompatActivity() {override fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)setContentView(R.layout.activity_main)// Jump to ConferenceGeneralActivityval intent = Intent(this, ConferenceGeneralActivity::class.java)startActivity(intent)}}
Conference main interface | User list |
| |
Was this page helpful?