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.** { *; }
tuilivekit/src/main/AndroidManifest.xml
。TUILogin.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 TUICallKit
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>
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";//Show the anchor preview page in the Activity. Click the Start Live button on the preview page to initiate live online videoFragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); TUILiveRoomAnchorFragment anchorFragment = new TUILiveRoomAnchorFragment(roomId); fragmentTransaction.add(R.id.fl_container, anchorFragment); fragmentTransaction.commit(); } }
Video Live Preview Screen | Live video streaming with pictures |
<?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>
public class AudienceActivity extends AppCompatActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.app_activity_audience); //RoomId is the id of the room where the broadcast room is createdString roomId = "123666";// Displays the audience page in the Activity FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); TUILiveRoomAudienceFragment audienceFragment = new TUILiveRoomAudienceFragment(roomId); fragmentTransaction.add(R.id.fl_container, audienceFragment); fragmentTransaction.commit(); } }
Video Live Room | Video Live Room |
Was this page helpful?