CloudHub Docs
Download Documents


Fast integration SDK


1.Projects that need to integrate SDK

2.cloudhub_rtc.aar package

Integrated SDK

Take AndroidStudio as an example::

1.Copy cloudhub_rtc.aar to the project, copy cloudhub_rtc.aar to the libs file of the Module in the project that needs to be integratedIn the folder, the libs folder needs to be at the same level as the src folder, as shown in the figure:


If the libs folder does not exist, right-click module-New-Directory, enter libs, create


2.Add dependency in gradle


At the same time, under the dependencies node, add api(name:'cloudhub_rtc',ext:'aar')as the picture show


If there are other modules that depend on adding aar's module, you need to add aar's dependency in other modules as well


3.Add permissions

<uses-permission android:name="android.permission.CAMERA"/>

<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>

<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>

<uses-permission android:name="android.permission.RECORD_AUDIO"/>

<uses-permission android:name="android.permission.BLUETOOTH"/>

<uses-permission android:name="android.permission.INTERNET"/>

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

Realize audio and video live broadcast

Create audio and video live broadcast interface

Create audio and video live broadcast user interface according to actual business scenarios

Can refer to Sample code in Android audio and video SDK DEMO

request permissions

Call the checkSelfPermission method to check and obtain the camera and microphone of the Android mobile device when the Activity is startedUse permissions.

private List<String> mPermissionList = new ArrayList<>();

private String[] mPermissions = new String[]{

protected void onCreate(Bundle savedInstanceState) {

public void requestPermission() {
    for (String permission : mPermissions) {
        if (ContextCompat.checkSelfPermission(this, permission) != PackageManager.PERMISSION_GRANTED) {
    if (!mPermissionList.isEmpty()) {
        ActivityCompat.requestPermissions(this, mPermissionList.toArray(new String[mPermissionList.size()]), 100);
    } else {

public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    if (requestCode == 100 && grantResults.length > 0) {
        boolean isFlage = false;
        for (int i = 0; i < grantResults.length; i++) {
            if (grantResults[i] == PackageManager.PERMISSION_DENIED) {
                isFlage = true;
                Toast.makeText(this, permissions[i] + getString(R.string.permission_denied), Toast.LENGTH_SHORT).show();

Initialize RtcEngine

Before calling other APIs, you need to create and initialize the RtcEngine object.

Prior to this, it is necessary to apply APPID, a reference to create an account and get AppId CloudHub

String appId = Constants.APPID;
RtcEngine.initEngine(getApplicationContext(), "Subscribe", null, appId);

You also need to register the callback event to monitor during initialization. For specific information about the event, refer to Overview

// Audio volume prompts time interval
// Enable Local Audio
// Enable Local Video
// Local HD Acquisition
// Sets the video encoding properties
RtcEngine.setVideoEncoderConfiguration(320, 240, 10, RtcEngine.ORIENTATION_MODE_ADAPTIVE);

Set user information

JSONObject properties = new JSONObject();
properties.put("username", mUserName);
properties.put("id", mMySelfId);

Join the channel

RtcEngine.joinChannel(mChannelId, mMySelfId, Constants.TOKEN, properties.toString());

Handle callbacks in the channel

According to the business requirements, it is processed in the related callback function. refer to RtcEngineListener

Leave channel

According to the needs of the scene, call leaveChannel to leave the current live channel.


More methods and sample code

Can refer to The method description in the overview andthe related implementation in the Android audio and video SDK DEMO