tencent cloud

All product documents
Cloud Contact Center
Last updated: 2025-01-09 15:41:51
Android
Last updated: 2025-01-09 15:41:51

Create Application and Event Callback

API
Description
sharedInstance
Creates a TCCCWorkstation instance (singleton).
destroySharedInstance
Destroys a TCCCWorkstation instance (singleton).
setListener
Sets a TCCCWorkstation event callback.

Sample Code for Creating Instances and Setting Event Callbacks

// Create an instance and set an event callback
TCCCWorkstation tcccSDK = TCCCWorkstation.sharedInstance(getApplicationContext());
tcccSDK.setListener(new TCCCListener() {});

Login API Functions

API
Description
login
SDK login
checkLogin
Checks whether the SDK is already logged in.
logout
SDK logout

Login Sample Code

TCCCTypeDef.TCCCLoginParams loginParams = new TCCCTypeDef.TCCCLoginParams();
/// The agent ID for login, which is usually an email address
loginParams.userId = "";
/// The login ticket, required for the Agent login mode. For details, see Creating SDK Login.
/// Token](https://www.tencentcloud.com/document/product/679/49227?from_cn_redirect=1)
loginParams.token = "";
/// Cloud Contact Center application ID, which usually starts with 1400
loginParams.sdkAppId = 0;
// Must be the Agent mode
loginParams.type = TCCCTypeDef.TCCCLoginType.Agent;

tcccSDK.login(loginParams, new TXCallback() {
@Override
public void onSuccess() {
// login success
}

@Override
public void onError(int code, String desc) {
// login error
}
});

Call API Functions

API
Description
call
Initiates a call
answer
Answers the inbound call
terminate
Ends the call
sendDTMF
Sends Dual-Tone Multi-Frequency (DTMF) signals
mute
Mute.
unmute
Unmute.

Sample Code for Initiating and Ending a Call

TCCCTypeDef.TCCCStartCallParams callParams =new TCCCTypeDef.TCCCStartCallParams();
//Format <scheme> : <user> @<host>, such as sip:1343xxxx@1400xxxx.tccc.qcloud.com, where 1343xxxx is a mobile phone number, and 1400xxxx is your TCCC application ID
callParams.to = "sip:1343xxxx@1400xxxx.tccc.qcloud.com";
// Initiate a call
tcccSDK.call(callParams, new TXCallback() {
@Override
public void onSuccess() {
// call success
}

@Override
public void onError(int code, String desc) {
// call error
}
});
// End the call
tcccSDK.terminate();

Audio Device API Functions

API
Description
setAudioCaptureVolume
Sets the local audio capture volume.
getAudioCaptureVolume
Obtains the local audio capture volume.
setAudioPlayoutVolume
Sets the remote audio prompt volume.
getAudioPlayoutVolume
Obtains the remote audio prompt volume.
setAudioRoute
Sets audio routing.

Debug APIs

API
Description
getSDKVersion
Get SDK version ID.
setLogLevel
Sets the log output level.
setConsoleEnabled
Enables/Disables console log print.
callExperimentalAPI
Calls an experimental API.

Sample Code for Get SDK Version

// Obtain SDK version number
TCCCWorkstation.getSDKVersion();

Error and Warning Events

API
Description
onError
Error event callback
onWarning
Warning event callback

Sample Code for Handling Error Event Callbacks

tcccSDK.setListener(new TCCCListener() {
/**
* Error event callback
* Error event, indicating that the SDK encounters an irrecoverable error, such as a failure of entering a room or a device startup failure
* @param errCode //Error code
* @param errMsg //Error message
* @param extraInfo Additional information field. Some error codes may carry additional information to help locate problems.
*/
@Override
public void onError(int errCode, String errMsg, Bundle extraInfo) {
super.onError(errCode, errMsg, extraInfo);
}

/**
* Warning event callback
* Warning event, indicating advisory issues thrown by the SDK, such as audio lag or high CPU utilization
* @param warningCode Warning code
* @param warningMsg Warning message
* @param extraInfo Additional information field. Some warning codes may carry additional information to help locate problems.
*/
@Override
public void onWarning(int warningCode, String warningMsg, Bundle extraInfo) {
super.onWarning(warningCode, warningMsg, extraInfo);
}
});

Call Event Callback

API
Description
onNewSession
New session event, including inbound and outbound calls
onEnded
Session End Event
onAudioVolume
Callback for volume feedback
onNetworkQuality
Real-time statistics callback of network quality

Sample Code for Answer and Agent Hang-up Event Callbacks

tcccSDK.setListener(new TCCCListener() {
@Override
public void onNewSession(TCCCTypeDef.ITCCCSessionInfo info) {
super.onNewSession(info);
// New session event, including inbound and outbound calls. The direction can be determined through info.sessionDirection
}

@Override
public void onEnded(int reason, String reasonMessage, String sessionId) {
super.onEnded(reason, reasonMessage, sessionId);
// End of session
}

@Override
public void onAccepted(String sessionId) {
super.onAccepted(sessionId);
// Counterpart answers
}
});

Event Callbacks for Cloud Connection Status

API
Description
onConnectionLost
The connection between the SDK and the cloud has been disconnected.
onTryToReconnect
The SDK is trying to reconnect to the cloud.
onConnectionRecovery
The connection between the SDK and the cloud has been restored.

Sample Code for Event Callback of Connection with Cloud

tcccSDK.setListener(new TCCCListener() {
/**
* The connection between the SDK and the cloud has been disconnected.
* The SDK triggers this event callback when it loses connection to the cloud, usually due to network issues or switching networks.
* For example, this can happen if a user enters an elevator during a call. After that, the SDK will try to reconnect to the cloud.
* During reconnection, SDK triggers **onTryToReconnect**, and once the connection is restored, it triggers **onConnectionRecovery**.
* Therefore, SDK transitions between these three connection-related events in the following sequence:
*/
@Override
public void onConnectionLost(TCCCServerType serverType) {
super.onConnectionLost(serverType);
}

/**
* The SDK is trying to reconnect to the cloud
* When the SDK's connection with the cloud is lost, it will throw onConnectionLost, after which it will strive to re-establish a connection with the cloud and throw this event.
* After the connection is restored, onConnectionRecovery is thrown.
*/
@Override
public void onTryToReconnect(TCCCServerType serverType) {
super.onTryToReconnect(serverType);
}

/**
* The connection between the SDK and the cloud has been restored.
* When the SDK's connection with the cloud is lost, it throws onConnectionLost, and then tries to re-establish a connection with the cloud and throws onTryToReconnect.
* This callback is thrown when the connection is restored.
*/
@Override
public void onConnectionRecovery(TCCCServerType serverType) {
super.onConnectionRecovery(serverType);
}
});


API Error Codes

Basic Error Codes

Symbol
Value
Meaning
ERR_SIP_SUCCESS
200
Execution succeeded.
ERR_UNRIGIST_FAILURE
20001
Login failed.
ERR_ANSWER_FAILURE
20002
Failed to answer the call, usually because the TRTC failed to enter the room.
ERR_SIPURI_WRONGFORMAT
20003
URI format error

SIP Error Codes

Symbol
Value
Meaning
ERR_SIP_BAD_REQUEST
400
Error request
ERR_SIP_UNAUTHORIZED
401
Unauthorized (username or password is incorrect)
ERR_SIP_AUTHENTICATION_REQUIRED
407
Proxy authentication required. Please check whether the login API has been called.
ERR_SIP_REQUESTTIMEOUT
408
Request timeout (network timeout)
ERR_SIP_REQUEST_TERMINATED
487
Request termination (network error, in case of network interruption)
ERR_SIP_SERVICE_UNAVAILABLE
503
Service unavailable
ERR_SIP_SERVER_TIMEOUT
504
Service timeout

Audio Device Error Codes

Symbol
Value
Meaning
ERR_MIC_START_FAIL
-1302
Failed to start the microphone. The device's microphone configuration program (driver) is abnormal. Please disable and re-enable the device, restart the device, or update the configuration program.
ERR_MIC_NOT_AUTHORIZED
-1317
No access to the microphone. This usually occurs on mobile devices and may be because the user denied the access.
ERR_MIC_SET_PARAM_FAIL
-1318
Failed to set microphone parameters.
ERR_MIC_OCCUPY
-1319
The microphone is occupied. This occurs when, for example, the user is currently having a call on the mobile device.
ERR_MIC_STOP_FAIL
-1320
Failed to stop the microphone.
ERR_SPEAKER_START_FAIL
-1321
Failed to start the speaker, for example, on Windows or Mac.
ERR_SPEAKER_SET_PARAM_FAIL
-1322
Failed to set speaker parameters.
ERR_SPEAKER_STOP_FAIL
-1323
Failed to stop the speaker.
ERR_UNSUPPORTED_SAMPLERATE
-1306
Unsupported audio sample rate

Network Error Codes

Symbol
Value
Meaning
ERR_RTC_ENTER_ROOM_FAILED
-3301
Failed to enter the room. Please check the error message corresponding to -3301 in onError to identify the cause of the failure.
ERR_RTC_REQUEST_IP_TIMEOUT
-3307
Request for IP and Sig timed out. Make sure the network is working and UDP is allowed through the firewall.
ERR_RTC_CONNECT_SERVER_TIMEOUT
-3308
Connection timed out. Check if the network is disconnected or a VPN is enabled. You can also try switching to 4G.
ERR_RTC_ENTER_ROOM_REFUSED
-3340
Room entry request was denied. Check if you're repeatedly calling enterRoom for the same room ID.

Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon