api("io.trtc.uikit:live-stream-core:latest.release")
api 'io.trtc.uikit:live-stream-core:latest.release'
-keep class com.tencent.** { *; }-keep class com.trtc.uikit.livekit.livestreamcore.** { *; }
// app/src/main/AndroidManifest.xml<application...// Add the following configuration to overwrite the configuration in the dependent SDKandroid:allowBackup="false"tools:replace="android:allowBackup">
// Log inTUILogin.login(applicationContext,1400000001, // Please replace it with the SDKAppID obtained in step 1"denny", // Please replace with your UserID"xxxxxxxxxxx", // You can calculate a UserSig in the console and fill it in this positionobject : TUICallback() {override fun onSuccess() {Log.i(TAG, "login success")}override fun onError(errorCode: Int, errorMessage: String) {Log.e(TAG, "login failed, errorCode: $errorCode msg:$errorMessage")}})
// Log inTUILogin.login(context,1400000001, // Please replace it with the SDKAppID obtained in step 1"denny", // Please replace with your UserID"xxxxxxxxxxx", // You can calculate a UserSig in the console and fill it in this positionnew 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);}});
Parameter | Type | Description |
SDKAppID | int | In the final step of step one, you have already obtained it, so it will not be repeated here. |
UserID | String | The ID of the current user, string type, is only allowed to contain letters (a-z and A-Z), numbers (0-9), hyphens, and underscores. |
userSig | String | Use the SecretKey obtained in Step One, Step 3 to encrypt information such as SDKAppID and UserID to obtain UserSig, which is a token for authentication used by Tencent Cloud to identify whether the current user can use TRTC services. You can generate a temporarily usable UserSig through the Auxiliary Tools in the console. For more information, see UserSig. |
GenerateTestUserSig.genTestSig
function to generate UserSig. In this method, the SDKSecretKey is vulnerable to decompilation and reverse engineering. If your key is leaked, attackers can steal your Tencent Cloud traffic.val livecoreView = LiveCoreView(this)
LiveCoreView liveCoreView = new LiveCoreView(this);
livecoreView.startCamera(true, null)
liveCoreView.startCamera(true, null);
val roomInfo = TUIRoomDefine.RoomInfo()roomInfo.roomId = "123456"livecoreView.startLiveStream(roomInfo, null)livecoreView.startMicrophone(null)
TUIRoomDefine.RoomInfo roomInfo = new TUIRoomDefine.RoomInfo();roomInfo.roomId = "roomId_123456";livecoreView.startLiveStream(roomInfo, null);livecoreView.startMicrophone(null);
livecoreView.joinLiveStream("roomId_123456", null)
livecoreView.joinLiveStream("roomId_123456", null);
The anchor opens the live broadcast room and starts the live broadcast | Viewers join the live broadcast room to watch the live broadcast |
|
|
// Set the grid layoutmLiveStreamListView.setLayoutMode(LiveCoreViewDefine.LayoutMode.GRID_LAYOUT, "")// Set the floating window layoutmLiveStreamListView.setLayoutMode(LiveCoreViewDefine.LayoutMode.FLOAT_LAYOUT, "")// Set custom layoutvar layoutJson = "{\\"1\\":{\\"backgroundColor\\":4095,\\"viewInfoList\\":[{\\"x\\":0.0,\\"y\\":0.0,\\"width\\":1.0,\\"height\\":-1.0,\\"zOrder\\":0,\\"backgroundColor\\":0}]},\\"2\\":{\\"backgroundColor\\":0,\\"viewInfoList\\":[{\\"x\\":0.0,\\"y\\":0.0,\\"width\\":1.0,\\"height\\":-1.0,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.789333333,\\"y\\":1.533333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0}]},\\"3\\":{\\"backgroundColor\\":4095,\\"viewInfoList\\":[{\\"x\\":0.0,\\"y\\":0.0,\\"width\\":1.0,\\"height\\":-1.0,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.789333333,\\"y\\":1.533333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.5,\\"y\\":1.165333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0}]},\\"4\\":{\\"backgroundColor\\":4095,\\"viewInfoList\\":[{\\"x\\":0.0,\\"y\\":0.0,\\"width\\":1.0,\\"height\\":-1.0,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.789333333,\\"y\\":1.533333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.5,\\"y\\":1.165333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.5,\\"y\\":0.797333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0}]},\\"5\\":{\\"backgroundColor\\":4095,\\"viewInfoList\\":[{\\"x\\":0.0,\\"y\\":0.0,\\"width\\":1.0,\\"height\\":-1.0,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.789333333,\\"y\\":1.533333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.5,\\"y\\":1.165333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.5,\\"y\\":0.797333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.789333333,\\"y\\":0.429333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0}]},\\"6\\":{\\"backgroundColor\\":0,\\"viewInfoList\\":[{\\"x\\":0.0,\\"y\\":0.0,\\"width\\":1.0,\\"height\\":-1.0,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.789333333,\\"y\\":1.533333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.5,\\"y\\":1.165333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.5,\\"y\\":0.797333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.789333333,\\"y\\":0.429333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.024,\\"y\\":0.429333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0}]},\\"7\\":{\\"backgroundColor\\":0,\\"viewInfoList\\":[{\\"x\\":0.0,\\"y\\":0.0,\\"width\\":1.0,\\"height\\":-1.0,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.789333333,\\"y\\":1.533333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.5,\\"y\\":1.165333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.5,\\"y\\":0.797333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.789333333,\\"y\\":0.429333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.024,\\"y\\":0.429333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.28,\\"y\\":0.797333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0}]},\\"8\\":{\\"backgroundColor\\":0,\\"viewInfoList\\":[{\\"x\\":0.0,\\"y\\":0.0,\\"width\\":1.0,\\"height\\":-1.0,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.789333333,\\"y\\":1.533333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.5,\\"y\\":1.165333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.5,\\"y\\":0.797333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.789333333,\\"y\\":0.429333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.024,\\"y\\":0.429333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.28,\\"y\\":0.797333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.28,\\"y\\":1.165333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0}]},\\"9\\":{\\"backgroundColor\\":4095,\\"viewInfoList\\":[{\\"x\\":0.0,\\"y\\":0.0,\\"width\\":1.0,\\"height\\":-1.0,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.789333333,\\"y\\":1.533333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.5,\\"y\\":1.165333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.5,\\"y\\":0.797333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.789333333,\\"y\\":0.429333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.024,\\"y\\":0.429333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.28,\\"y\\":0.797333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.28,\\"y\\":1.165333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.024,\\"y\\":1.533333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0}]}}";mLiveStreamListView.setLayoutMode(LiveCoreViewDefine.LayoutMode.FREE_LAYOUT, layoutJson)
// Set the grid layoutmLiveStreamListView.setLayoutMode(LiveCoreViewDefine.LayoutMode.GRID_LAYOUT, "");// Set the floating window layoutmLiveStreamListView.setLayoutMode(LiveCoreViewDefine.LayoutMode.FLOAT_LAYOUT, "");// Set custom layoutString layoutJson = "{\\"1\\":{\\"backgroundColor\\":4095,\\"viewInfoList\\":[{\\"x\\":0.0,\\"y\\":0.0,\\"width\\":1.0,\\"height\\":-1.0,\\"zOrder\\":0,\\"backgroundColor\\":0}]},\\"2\\":{\\"backgroundColor\\":0,\\"viewInfoList\\":[{\\"x\\":0.0,\\"y\\":0.0,\\"width\\":1.0,\\"height\\":-1.0,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.789333333,\\"y\\":1.533333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0}]},\\"3\\":{\\"backgroundColor\\":4095,\\"viewInfoList\\":[{\\"x\\":0.0,\\"y\\":0.0,\\"width\\":1.0,\\"height\\":-1.0,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.789333333,\\"y\\":1.533333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.5,\\"y\\":1.165333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0}]},\\"4\\":{\\"backgroundColor\\":4095,\\"viewInfoList\\":[{\\"x\\":0.0,\\"y\\":0.0,\\"width\\":1.0,\\"height\\":-1.0,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.789333333,\\"y\\":1.533333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.5,\\"y\\":1.165333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.5,\\"y\\":0.797333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0}]},\\"5\\":{\\"backgroundColor\\":4095,\\"viewInfoList\\":[{\\"x\\":0.0,\\"y\\":0.0,\\"width\\":1.0,\\"height\\":-1.0,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.789333333,\\"y\\":1.533333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.5,\\"y\\":1.165333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.5,\\"y\\":0.797333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.789333333,\\"y\\":0.429333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0}]},\\"6\\":{\\"backgroundColor\\":0,\\"viewInfoList\\":[{\\"x\\":0.0,\\"y\\":0.0,\\"width\\":1.0,\\"height\\":-1.0,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.789333333,\\"y\\":1.533333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.5,\\"y\\":1.165333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.5,\\"y\\":0.797333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.789333333,\\"y\\":0.429333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.024,\\"y\\":0.429333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0}]},\\"7\\":{\\"backgroundColor\\":0,\\"viewInfoList\\":[{\\"x\\":0.0,\\"y\\":0.0,\\"width\\":1.0,\\"height\\":-1.0,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.789333333,\\"y\\":1.533333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.5,\\"y\\":1.165333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.5,\\"y\\":0.797333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.789333333,\\"y\\":0.429333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.024,\\"y\\":0.429333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.28,\\"y\\":0.797333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0}]},\\"8\\":{\\"backgroundColor\\":0,\\"viewInfoList\\":[{\\"x\\":0.0,\\"y\\":0.0,\\"width\\":1.0,\\"height\\":-1.0,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.789333333,\\"y\\":1.533333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.5,\\"y\\":1.165333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.5,\\"y\\":0.797333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.789333333,\\"y\\":0.429333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.024,\\"y\\":0.429333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.28,\\"y\\":0.797333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.28,\\"y\\":1.165333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0}]},\\"9\\":{\\"backgroundColor\\":4095,\\"viewInfoList\\":[{\\"x\\":0.0,\\"y\\":0.0,\\"width\\":1.0,\\"height\\":-1.0,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.789333333,\\"y\\":1.533333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.5,\\"y\\":1.165333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.5,\\"y\\":0.797333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.789333333,\\"y\\":0.429333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.024,\\"y\\":0.429333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.28,\\"y\\":0.797333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.28,\\"y\\":1.165333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0},{\\"x\\":0.024,\\"y\\":1.533333333,\\"width\\":0.186666666,\\"height\\":0.368,\\"zOrder\\":0,\\"backgroundColor\\":0}]}}";mLiveStreamListView.setLayoutMode(LiveCoreViewDefine.LayoutMode.FREE_LAYOUT, layoutJson);
Anchor is online - Nine-grid layout | Anchor is online-Floating window layout | Anchor is online-Custom layout |
| | |
Was this page helpful?