tencent cloud

Android SDK Integration for Large Screen Devices
Last updated:2025-11-05 10:05:58
Android SDK Integration for Large Screen Devices
Last updated: 2025-11-05 10:05:58

Software and Hardware Requirements

System
Support Android 6 and later systems
Processor Architecture
Support arm64-v8a CPU architecture
Processor Performance Requirements
Support Rockchip RK3588
Development IDE
Android Studio
Memory Requirements
More than 500 MB

Model Package Description

The model package is divided into Base Model Package and Character Model Package, with detailed introduction as follows:

Base Model Package

The Base Model Package is irrelevant to avatars and is required for running 2D endpoint rendering. The model package directory is named: common_model/. If there are multiple character models, they can share one Base Model Package.

Character Image Pack

The Character Model Package contains image data and inference models for 2D Digital Human. Each character has one model package. Just load different character model packages to change avatars. The model package directory is named: human_xxxxx_540p_v2/, where xxxxx is the name of the custom avatar.
Currently, the SDK package includes one public image with the package name: human_yunxi_540p_v2, which can be used directly.
Note:
The SDK integration party needs to place the model package into the App sandbox. When initializing the SDK, pass the absolute paths of the two models as arguments to the SDK.
The model package can be dynamically downloaded. The dynamic download and update logic need to be connected by the App implementing your own.

Authorization Methods

The large-screen rendering SDK is licensed via device quantity. Please confirm the applied License is the large-screen rendering type.
A new device consumes one License quota on first startup. Ensure the License has remaining quota, otherwise it may lead to authentication failure.

Digital Human Client-Side Rendering SDK Integration

The calling process of Digital Human SDK is as follows:


Adding aar Package and Third-Party Library

Import the aar package of Digital Human rendering SDK to the project. The filename is: virtualhuman_2d_sdk_v202502071637.aar
Since OkHttp library is used, it is necessary to add the OkHttp dependency to the build.gradle (Module:app) file.
dependencies {
implementation fileTree(dir: 'libs', include: ['*.aar'])
// Add dependency
implementation 'com.squareup.okhttp3:okhttp:4.9.0'
implementation 'com.parse.bolts:bolts-tasks:1.4.0'
}

Setting Log Level and Callback Function

// Set log level
VirtualHumanController.setLogLevel(Int level);
// Set log callback
VirtualHumanController.setLogCallback(IDataCallback logCallback);
Log level
Log level
level Flag
Close logs
0
Error logs
1
Warning logs
2
Log information
3
Debug Logs
4
Trace logs
5

IDataCallbackCallback Parameters
Parameter Name
Data Type
Parameter Type
Description
level
Int
Required or Not
Log level
logMsg
String
Required
Log information

Creating a Digital Human Controller (VirtualHumanController)

VirtualHumanParam vhParam = new VirtualHumanParam();
// Local model path
vhParam.humanModelPath = "/data/user/0/com.tencent.virtualhuman_2d_demo/files/test_model/human_model";
// Local model path
vhParam.commonModelPath = "/data/user/0/com.tencent.virtualhuman_2d_demo/files/test_model/common_model";
vhParam.appId = "License appId";
vhParam.secretKey = "License secretKey";
vhParam.deviceName = "Device tag, use nameplate info";

// error callback function
vhParam.errorCallback = (code, message) -> {
Log.d(TAG, "Code: " + code + ", Message: " + message);
};
// event callback function
vhParam.eventCallback = (code, message) -> {
Log.d(TAG, "Code: " + code + ", Message: " + message);
};
controller = new VirtualHumanController(this, vhParam);
int ret = controller.initHuman();
if (ret == 0) {
controller.setRenderView(virtualHumanView); // set rendering view
controller.startHuman();// Start rendering
} else {
Log.i(TAG, "init fail=" + ret);
}
VirtualHumanParam parameter description
Parameter Name
Data Type
Required
Description
humanModelPath
String
Yes
Local model path.
commonModelPath
String
Yes
Local general model path.
appId
String
Yes
AppId in the License.
secretKey
String
Yes
SecretKey in the License.
eventCallback
IDataCallback
No
Event callback function Event notification
eventCallback
IDataCallback
Yes
Exception callback function, monitoring exception messages.
deviceName
String
No
Device alias. Use nameplate info.
IDataCallback
Parameter Name
Data Type
Required
Description
code
Int
Yes
code
message
String
Yes
Information
Error list (continuously supplement)
Error Code
Error Message
20001
Algorithm model initialization error.
20010
Authentication failed.
20012
Insufficient device performance, cannot operate smoothly.
Information list
Error Code
Error Message
10001
Broadcast started.
10002
Broadcast ended.
10003
controller.appendAudioData('audio data', boolean, 'tag').
When calling appendAudioData with a tag parameter, 10003 represents the start event for playing this audio data, and the tag is returned in the callback event.
10004
controller.appendAudioData('audio data', boolean, 'tag').
When calling appendAudioData with a tag parameter, 10003 represents the end event for playing this audio data, and the tag is returned in the callback event.
10005
Callback event for the first-frame image rendering of Digital Human.

Creating a Digital Human View (VirtualHumanView)

VirtualHumanView is the foundation view for Digital Human rendering. The connecting party can use VirtualHumanView in Activity or any view for display. You can configure it in two ways:
Configure directly in XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:id="@+id/ll_floating_ball"
android:layout_width="180dp"
android:layout_height="320dp"
android:background="#8f15ab71"
android:gravity="center"
android:orientation="horizontal">

<com.tencent.virtualhuman_2d_sdk.VirtualHumanView
android:id="@+id/virtual_human_view"
app:TVHFillMode="fill" // render View filling mode
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</LinearLayout>
Dynamically increase:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:id="@+id/ll_container"
android:layout_width="480dp"
android:layout_height="480dp"
android:background="#8f15ab71"
android:gravity="center"
android:orientation="horizontal">
</LinearLayout>
</LinearLayout>
Example Code
// context is the context of the current Activity interface
VirtualHumanView virtualHumanView = new VirtualHumanView(context);
virtualHumanView.setFillMode(VirtualHumanViewType.fill);
LinearLayout ll_container = findViewById(R.id.ll_container);
ll_container.addView(virtualHumanView);
You can set the fill mode of the render View:
VirtualHumanViewType.stretch
Stretch image
VirtualHumanViewType.fit
Crop image
VirtualHumanViewType.fill
Keep black border (transparent edge)

Setting Render View for Controller

Parameter description
Parameter Name
Data Type
Parameter Type
Description
virtualHumanView
VirtualHumanView
Required
controller.setRenderView(virtualHumanView);

Streaming Input Audio-Driven Digital Human

The input audio format is s16le (signed 16 bits little endian) PCM, with a sampling rate of 16000 and mono.
Parameter Name
Data Type
Parameter Type
Description
decodedBytes
Byte[]
Yes
PCM audio data.
isFinal
Boolean
Yes
Whether it is the last audio frame.
metaData
String
No
Import the tag corresponding to the audio data. There will be event 10003/10004 when broadcasting the audio fragment.
Example Code
controller.appendAudioData(decodedBytes, isFinal);
controller.appendAudioData(decodedBytes, isFinal, metaData);

Interrupt Request

Sample Code
controller.interrupt();

Suspending a Request

Sample Code
controller.pause();

Restoring a Request

Sample Code
controller.resume();

9. Stutter Optimization

If stuttering occurs when a specific device is running, you can try calling the following 2 APIs separately:
controller.setDualGen(true);// Enable dual-core algorithm logic
controller.setSkipFrameInterval(5);// Skip 1 frame every 5 frames to reduce compute consumption

Demo App Running Instructions

The SDK includes a fully functional Demo App. The project structure is as follows:


Modify the local.properties File

The local.properties file contains all keys used, such as AppKey. Please change to the customer application.


2 Run Demo

Click the Run button to run the 2D endpoint rendering Demo application as soon as.

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

Feedback