jitpack
repository dependencies to your project (Download the three-party library SVGAPlayer
that plays gift svg animation):build.gradle
file in the root directory of the project:allprojects { repositories { google() mavenCentral()// add jitpack repository maven { url 'https://jitpack.io' } } }
settings.gradle
file in the root directory of the project:dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral()// add jitpack repository maven { url 'https://jitpack.io' } } }
settings.gradle
file in the project root directory and add the following code to it. Its function is to import the tuilivekit component downloaded in Step 2 into your current project:include ':tuilivekit'
build.gradle
file in the app directory and add the following code to it. Its function is to declare the dependence of the current app on the newly added tuilivekit component:api project(':tuilivekit')
TRTC SDK
、IM SDK
、tuiroomengine
and the public library tuicore
, and does not require separate configuration by developers. If you need to upgrade the version, just modify the tuilivekit/build.gradle
file.proguard-rules.pro
file:-keep class com.tencent.** { *; }
AndroidManifest.xml
, set a Theme.AppCompat
Theme to the android:theme
attribute of application
:<?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 android:theme="@style/Theme.AppCompat.DayNight.NoActionBar">...</application></manifest>
tuilivekit/src/main/AndroidManifest.xml
。AndroidManifest.xml,
please refer to allowBackup Exceptions.Theme.AppCompat
, please refer to Activity theme issue.import TUICoreTUILogin.login(context,1400000001, // Replace it with the SDKAppID obtained in Step 1"denny", // Please replace it with your UserID"xxxxxxxxxxx", // You can calculate a UserSig in the console and fill it innew TUICallback() {@Overridepublic void onSuccess() {Log.i(TAG, "login success");}@Overridepublic void onError(int errorCode, String errorMessage) {Log.e(TAG, "login failed, errorCode: " + errorCode + " msg:" + errorMessage);}});
login
function are as detailed below:SDKSecretKey
to encrypt the information such as SDKAppID
and UserID
. You can generate a temporary UserSig
by clicking the UserSig Generate button in the console.genTestUserSig
function to calculate UserSig
locally, so as to help you complete the current integration process more quickly. However, this scheme exposes your SecretKey
in the application code, which makes it difficult for you to upgrade and protect your SecretKey
subsequently. Therefore, we strongly recommend you run the UserSig
calculation logic on the server and make the application request the UserSig
calculated in real time every time the application uses the TUILiveKit
component from the server.<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <FrameLayout android:id="@+id/fl_container" android:layout_width="match_parent" android:layout_height="match_parent" /> </RelativeLayout>
AnchorActivity.java
and register in the AndroidManifest.xml
. By loading TUILiveKit TUIVoiceRoomFragment page, you can pull up preview screen.public class AnchorActivity extends AppCompatActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.app_activity_anchor); //RoomId can be customizedString roomId = "123666";LiveDefine.RoomParams params = new LiveDefine.RoomParams();//The default value is the maximum number of seat supported by the package params.maxSeatCount = 0; params.seatMode = TUIRoomDefine.SeatMode.APPLY_TO_TAKE;FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); TUIVoiceRoomFragment fragment = new TUIVoiceRoomFragment(roomId,LiveDefine.RoomBehavior.PREPARE_CREATE, params); fragmentTransaction.add(R.id.fl_container, fragment); fragmentTransaction.commit(); } }
AnchorActivity
in AndroidManifest.xml
of the app Project (please use the actual package name of your AnchorActivity
):<?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>...<!-- Example: To register AnchorActivity, please use your actual package name --><activity android:name="com.trtc.uikit.livekit.example.main.AnchorActivity"android:theme="@style/Theme.AppCompat.DayNight.NoActionBar"/>...</application></manifest>
AnchorActivity
inherited from AppCompatActivity
, AnchorActivity
was given a Theme.AppCompat
theme. You can modify it to your own Theme.AppCompat
theme.Intent intent = new Intent(context, AnchorActivity.class); startActivity(intent);
Voice chat room preview screen | Voice chat room in-room screen |
| |
TUILogin.login
has successfully logged in.<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <FrameLayout android:id="@+id/fl_live_list" android:layout_width="match_parent" android:layout_height="match_parent" /> </RelativeLayout>
AndroidManifest.xml
, and by loading the TUILiveKit page of TUILiveListFragment
, you can display the room list.public class MainActivity extends AppCompatActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.app_activity_main);FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); TUILiveListFragment listFragment = new TUILiveListFragment(); fragmentTransaction.add(R.id.fl_live_list, listFragment); fragmentTransaction.commit(); } }
MainActivity
in the app's AndroidManifest.xml
(use your actual package name for MainActivity
):<?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>...<!-- Example: Register MainActivity, please use your actual package name --><activityandroid:name="com.trtc.uikit.livekit.example.view.main.MainActivity"android:theme="@style/Theme.AppCompat.DayNight.NoActionBar"/>...</application></manifest>
MainActivity
inherits fromAppCompatActivity
, you need to set aTheme.AppCompat
theme forMainActivity
. You can modify it to your ownTheme.AppCompat
theme.<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <FrameLayout android:id="@+id/fl_container" android:layout_width="match_parent" android:layout_height="match_parent" /> </RelativeLayout>
AudienceActivity.java
and register in the AndroidManifest.xml
. By loading TUILiveKit TUILiveRoomAudienceFragment
page, you can enter room.public class AudienceActivity extends AppCompatActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.app_activity_audience); //RoomId can be customizedString roomId = "123666";FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); TUIVoiceRoomFragment fragment = new TUIVoiceRoomFragment(roomId,LiveDefine.RoomBehavior.JOIN, null); fragmentTransaction.add(R.id.fl_container, fragment); fragmentTransaction.commit(); } }
AudienceActivity
in AndroidManifest.xml
of the app Project (please use the actual package name of your AudienceActivity
):<?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>...<!-- Example: To register AudienceActivity, please use your actual package name --><activity android:name="com.trtc.uikit.livekit.example.main.AudienceActivity"android:theme="@style/Theme.AppCompat.DayNight.NoActionBar"/>...</application></manifest>
AnchorActivity
inherited from AudiencetActivity
, AudiencetActivity
was given a Theme.AppCompat
theme. You can modify it to your own Theme.AppCompat
theme.Intent intent = new Intent(context, AudienceActivity.class); startActivity(intent);
Voice Chat Room | Voice Chat Room |
| |
Was this page helpful?