Call | Answer |
| |
TUICalling
component. You no longer need to pay attention to UI as it is now implemented within the TUICalling
component.TestVideoCall
and click Create.Android/Debug/src/main/java/com/tencent/liteav/debug/GenerateTestUserSig.java
.GenerateTestUserSig.java
:UserSig
described in this document involves configuring SECRETKEY
in client code. In this method, SECRETKEY
may be easily decompiled and reversed, and if your key is disclosed, attackers can steal your Tencent Cloud traffic. Therefore, this method is suitable only for the local execution and debugging of the app.UserSig
distribution method is to integrate the calculation code of UserSig
into your server and provide an application-oriented API. When UserSig
is needed, your application can send a request to the business server for a dynamic UserSig
. For more information, see How do I calculate UserSig on the server?.TUICalling
with Android Studio (version 3.5 or above) and click Run.userId
of the person you want to call and tap Search.Source
folder contains two subfolders: ui
and model
. The model
subfolder includes the open-source TUICallingManager
component, which we share with the public. You can find the component’s APIs in the TUICalling.java
file.TUICalling
and TUICallingManager
components, with no need to implement complicated call UI or logic by yourself.TUICalling
depends on the TRTC SDK and IM SDK. Follow the steps below to integrate the two SDKs into your project:dependencies
.dependencies {compile "com.tencent.liteav:LiteAVSDK_TRTC:latest.release"compile 'com.tencent.imsdk:imsdk:latest.release'// As we use Gson for parsing, you also need to add the Google Gson dependency.compile 'com.google.code.gson:gson:latest.release'}
defaultConfig
, specify the CPU architecture to be used by your application.defaultConfig {ndk {abiFilters "armeabi-v7a"}}
SDK | Download Page | Integration Guide |
TRTC SDK | ||
IM SDK |
AndroidManifest.xml
. The SDKs need the following permissions (on Android 6.0 and above, the camera and read storage permissions must be requested at runtime.)<uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /><uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /><uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /><uses-permission android:name="android.permission.RECORD_AUDIO" /><uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /><uses-permission android:name="android.permission.BLUETOOTH" /><uses-permission android:name="android.permission.CAMERA" /><uses-permission android:name="android.permission.READ_PHONE_STATE" /><uses-feature android:name="android.hardware.camera"/><uses-feature android:name="android.hardware.camera.autofocus" />
proguard-rules.pro
file, add the SDK classes to the "do not obfuscate" list.-keep class com.tencent.** { *;}
TUICalling
componentSource
directory to your project and import it in setting.gradle
as shown below:include ':Source'
TUICallingManager.sharedInstance()
to initialize the component.TUILogin.init(context, SDKAppID, config, listener)
to initialize login.TUILogin.login(userId, userSig, callback)
to log in to the component. Specify the key parameters as described below:Parameter | Description |
SDKAppID | |
userId | ID of the current user, which is a string that can contain letters (a-z and A-Z), digits (0-9), hyphens (-), and underscores (_). We recommend you set it based on your business account system. |
userSig | |
config | SDK configuration, which is used to set the log output level and log callback. You can pass null for this parameter. For details, see the sample code below. |
listener | IM listener, which is used to listen for some crucial callbacks, such as forced logout and userSig expiration. For details, see the sample code below. |
callback | Callback for login, which indicates whether login is successful. For details, see the sample code below. |
// Initialize the componentTUICallingManager manager = TUICallingManager.sharedInstance();// Log in to the componentV2TIMSDKConfig config = new V2TIMSDKConfig();config.setLogLevel(V2TIMSDKConfig.V2TIM_LOG_DEBUG);config.setLogListener(new V2TIMLogListener() {@Overridepublic void onLog(int logLevel, String logContent) {}});TUILogin.init(this, ${Your `SDKAPPID`}, config, new V2TIMSDKListener() {@Overridepublic void onKickedOffline() { // Callback for forced logoutmIsKickedOffline = true;checkUserStatus();}@Overridepublic void onUserSigExpired() { // Callback for `userSig` expirationmIsUserSigExpired = true;checkUserStatus();}});TUILogin.login("${Your `userId`}", "${Your `userSig`}", new V2TIMCallback() {@Overridepublic void onError(int code, String msg) {Log.d(TAG, "code: " + code + " msg:" + msg);}@Overridepublic void onSuccess() {Log.d(TAG, "onSuccess");}});
call();
of TUICallingManager
to initiate a call, passing in the user IDs (userids
) and call type (type
). For the call type, you can pass in TUICalling.Type.AUDIO
(audio call) or TUICalling.Type.VIDEO
(video call). If only one user ID is passed in for userids
, the call is a one-to-one call; if two or more user IDs are passed in, the call is a group call.// 1. Initialize the componentTUICallingManager manager = TUICallingManager.sharedInstance();// 2. Register the listenermanager.setCallingListener(new TUICalling.TUICallingListener() {@Overridepublic boolean shouldShowOnCallView() {return true;}@Overridepublic void onCallStart(String[] userIDs, TUICalling.Type type, TUICalling.Role role, final View tuiCallingView) {if (!shouldShowOnCallView() || null == tuiCallingView) {return;}runOnUiThread(new Runnable() {@Overridepublic void run() {FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);mCallingView = tuiCallingView;addContentView(tuiCallingView, params);}});}@Overridepublic void onCallEnd(String[] userIDs, TUICalling.Type type, TUICalling.Role role, long totalTime) {removeView();}@Overridepublic void onCallEvent(TUICalling.Event event, TUICalling.Type type, TUICalling.Role role, String message) {if (TUICalling.Event.CALL_FAILED == event) {removeView();}}});// 3. Make a callmanager.call(userIDs, TUICalling.Type.VIDEO);
sendModel
) of TRTCCallingImpl
. After completing the offline push configuration for your application, you will be able to send notifications to offline users.TUICalling
component.API | Description |
call | Sends call invitations by user ID. |
receiveAPNSCalled | Answers a call. |
setCallingListener | Sets the listener. |
setCallingBell | Sets the ringtone (preferably shorter than 30s). |
enableMuteMode | Enables/Disables the mute mode. |
enableCustomViewRoute | Enables/Disables custom views. After enabling custom views, you will receive a CallingView instance in the callback for calling/being called, and can decide how to display the view by yourself. The view must be displayed full screen or in proportion to the screen size; otherwise, an error may occur. |
Was this page helpful?