Skip to main content

Classroom client SDK

This page provides the Kotlin API reference of the Agora Classroom SDK for Android.

AgoraClassSdk

AgoraClassSdk is the basic interface of the Agora Classroom SDK and provides the main methods that can be invoked by your app.

version


_1
public static String version();

Gets the SDK version.

Returns

The SDK version.

setConfig


_1
public static void setConfig(AgoraEduSDKConfig agoraEduSDKConfig);

Globally configures the SDK.

Sample code


_6
/** Global Configuration */
_6
// Agora App ID
_6
String appId = "XXX";
_6
// Whether to enable eye care mode
_6
boolean eyeCare = false;
_6
AgoraClassSdk.setConfig(new AgoraClassSdkConfig(appId, eyeCare));

Parameter

ParameterDescription
agoraEduSDKConfigThe SDK global configuration. See AgoraClassSdkConfig.

launch


_3
public static AgoraEduClassRoom launch(@NotNull Context context,
_3
@NotNull AgoraEduLaunchConfig config,
_3
@NotNull AgoraEduLaunchCallback callback);

Launches a flexible classroom.

Sample code


_30
/** Classroom launching configuration */
_30
// The user name
_30
String userName = "XXX";
_30
// The user ID. Must be the same as the user ID that you use for generating an RTM token.
_30
String userUuid = "XXX";
_30
// The classroom name
_30
String roomName = "XXX";
_30
// The classroom ID
_30
String roomUuid = "XXX";
_30
// The user role
_30
int roleType = AgoraEduRoleType.AgoraEduRoleTypeStudent.getValue();
_30
// The classroom type
_30
int roomType = AgoraEduRoomType.AgoraEduRoomType1V1.getValue()/AgoraEduRoomType.AgoraEduRoomTypeSmall.getValue()/AgoraEduRoomType.AgoraEduRoomTypeBig.getValue();
_30
// The RTM token
_30
String rtmToken = "";
_30
// The start time (ms) of the class, determined by the first user joining the classroom.
_30
long startTime = System.currentTimeMillis() + 100;
_30
// The duration (ms) of the class, determined by the first user joining the classroom.
_30
long duration = 310L;
_30
// The region where the classroom is located. All clients must set the same region, otherwise, they may fail to communicate with each other.
_30
String region = AgoraEduRegion.cn;
_30
_30
AgoraEduLaunchConfig agoraEduLaunchConfig = new AgoraEduLaunchConfignew AgoraEduLaunchConfig(
_30
userName, userUuid, roomName, roomUuid, roleType,
_30
roomType, rtmToken, startTime, duration, region, null, null,
_30
AgoraBoardFitMode.Retain, streamState, AgoraEduLatencyLevel.AgoraEduLatencyLevelUltraLow,
_30
null, null);
_30
AgoraClassSdk.launch(MainActivity2.this, agoraEduLaunchConfig, (state) -> {
_30
Log.e(TAG, "launch-classroom-state:" + state.name());
_30
});

Parameter

ParameterDescription
contextThe context of the app.
configThe classroom launching configuration. See AgoraEduLaunchConfig.
callbackThe SDK uses the AgoraEduLaunchCallback class to report events related to classroom launching to the app.

Returns

The AgoraEduClassRoom class.

configCourseWare


_1
public static void configCourseWare(@NotNull List<AgoraEduCourseware> coursewares);

Configures courseware downloading.

Sample code


_22
/** Construct and configure courseware */
_22
// Configure the courseware
_22
String taskUuid = "xxxxx";
_22
// The courseware download address
_22
String resourceUrl = String.formate("https://convertcdn.netless.link/dynamicConvert/{taskUuid}.zip", taskUuid);
_22
// The courseware name
_22
String resourceName = "xxxxxxx"
_22
// The list of courseware pages
_22
List<SceneInfo> sceneInfos = new ArrayList();
_22
// The link of a converted page
_22
String src = "http://xxxxxxx";
_22
Ppt ppt = new Ppt(src, 360, 640);
_22
SceneInfo sceneInfo = new SceneInfo(1, ppt, "ppt-file-name");
_22
List<SceneInfo> sceneInfos = new ArrayList();
_22
sceneInfos.add(sceneInfo);
_22
// The path for storing the courseware
_22
String scenePath = resourceName + "/" + sceneInfos.get(0).name;
_22
AgoraEduCourseware courseware = new AgoraEduCourseware(resourceName, scenePath, sceneInfos, resourceUrl);
_22
List<AgoraEduCourseware> wares = new ArrayList();
_22
wares.add(courseware);
_22
// Configure the courseware pre-downloading
_22
configCoursewares(wares);

Parameter

ParameterDescription
waresThe courseware pre-download configuration. See AgoraEduCourseware.

downloadCourseWare


_2
public static void downloadCourseWare(@NotNull Context context, @Nullable AgoraEduCoursewarePreloadListener listener)
_2
throws Exception;

Pre-downloads the courseware.

Sample code


_15
// Download the configured courseware
_15
downloadCoursewares(activityContext, new AgoraEduCoursewarePreloadListener() {
_15
@Override
_15
public void onStartDownload(@NotNull AgoraEduCourseware ware) {
_15
}
_15
@Override
_15
public void onProgress(@NotNull AgoraEduCourseware ware, double progress) {
_15
}
_15
@Override
_15
public void onComplete(@NotNull AgoraEduCourseware ware) {
_15
}
_15
@Override
_15
public void onFailed(@NotNull AgoraEduCourseware ware) {
_15
}
_15
});

Parameter

ParameterDescription
contextThe context of the app.
listenerThe SDK reports events related to courseware preloading to the app through the AgoraEduCoursewarePreloadListener class.

registerExtensionApp


_1
public static void registerExtensionApp(List<AgoraExtAppConfiguration> apps);

Register an extension application by using the ExtApp tool. ExtApp is a tool for embedding extension applications in Flexible Classroom. For details, see Customize Flexible Classroom with ExtApp.

AgoraEduLaunchCallback

The AgoraEduLaunchCallback class reports events related to classroom launching to the app.

onCallback


_1
void onCallback(AgoraEduEvent state);

Reports classroom events.

ParameterDescription
stateThe classroom events. See AgoraEduEvent.

AgoraEduCoursewarePreloadListener

The AgoraEduCoursewarePreloadListener class reports events related to courseware preloading to the app.

onStartDownload


_1
void onStartDownload(@NotNull AgoraEduCourseware ware);

Indicates that the SDK starts downloading the courseware.

ParameterDescription
wareThe courseware pre-download configuration. See AgoraEduCourseware.

onProgress


_1
void onProgress(@NotNull AgoraEduCourseware ware, double progress);

Indicates the progress of courseware pre-downloading.

ParameterDescription
wareThe courseware pre-download configuration. See AgoraEduCourseware.
progressIndicates the progress of courseware pre-downloading.

onComplete


_1
void onComplete(@NotNull AgoraEduCourseware ware);

Indicates that the courseware pre-downloading completes.

ParameterDescription
wareThe courseware pre-download configuration. See AgoraEduCourseware.

onFailed


_1
void onFailed(@NotNull AgoraEduCourseware ware);

The courseware pre-downloading fails.

ParameterDescription
wareThe courseware pre-download configuration. See AgoraEduCourseware.

Type definition

AgoraClassSdkConfig


_5
public class AgoraClassSdkConfig {
_5
@NotNull
_5
private String appId;
_5
private int eyeCare;
_5
}

The SDK global configuration. Used in setConfig.

AttributesDescription
appIdThe Agora App ID. See Get the Agora App ID.
eyeCareWhether to enable eye care mode:
  • 0: (Default) Disable eye care mode.
  • 1: Enable eye care mode.
  • AgoraEduLaunchConfig


    _17
    class AgoraEduLaunchConfig(val userName: String,
    _17
    val userUuid: String,
    _17
    val roomName: String,
    _17
    val roomUuid: String,
    _17
    val roleType: Int = AgoraEduRoleType.AgoraEduRoleTypeStudent.value,
    _17
    val roomType: Int,
    _17
    val rtmToken: String,
    _17
    val startTime: Long?,
    _17
    val duration: Long?,
    _17
    val region: String,
    _17
    var videoEncoderConfig: EduVideoEncoderConfig? = null,
    _17
    val mediaOptions: AgoraEduMediaOptions?,
    _17
    val boardFitMode: AgoraBoardFitMode,
    _17
    val streamState: StreamState?,
    _17
    val latencyLevel: AgoraEduLatencyLevel? = AgoraEduLatencyLevel.AgoraEduLatencyLevelUltraLow,
    _17
    val userProperties: MutableMap<String, String>? = null,
    _17
    val widgetConfigs: MutableList<UiWidgetConfig>? = null) : Parcelable

    The classroom launching configuration. Used in launch.

    AttributesDescription
    userNameThe user name for display in the classroom. The string length must be less than 64 bytes.
    userUuidThe user ID. This is the globally unique identifier of a user. Must be the same as the User ID that you use for generating an RTM token. The string length must be less than 64 bytes. Supported character scopes are:
  • All lowercase English letters: a to z.
  • All numeric characters.
  • 0-9
  • The space character.
  • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " , ", "|", "~", ","
  • roomNameThe room name for display in the classroom. The string length must be less than 64 bytes.
    roomUuidThe room ID. This is the globally unique identifier of a classroom. The string length must be less than 64 bytes. Supported character scopes are:
  • All lowercase English letters: a to z.
  • All numeric characters.
  • 0-9
  • The space character.
  • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " , ", "|", "~", ","
  • roleTypeThe role of the user in the classroom. See AgoraEduRoleType.
    roomTypeThe classroom type. See AgoraEduRoomType.
    rtmTokenThe RTM token used for authentication. For details, see Generate an RTM Token.
    startTimeThe start time (ms) of the class, determined by the first user joining the classroom.
    durationThe duration (ms) of the class, determined by the first user joining the classroom.
    regionThe region where the classrooms is located. All clients must use the same region, otherwise, they may fail to communicate with each other. See AgoraEduRegionStr.
    videoEncoderConfigVideo encoding configurations, including the width and height, frame rate, and bitrate. See EduVideoEncoderConfig
    mediaOptionsThe media options, including media encryption configurations. See AgoraEduMediaOptions.
    boardFitModeThe PPT display mode. See AgoraBoardFitMode.
    streamStateControls whether students automatically send audio or video streams after they go onto the "stage". See StreamState.
    latencyLevelThe latency level of an audience member. See AgoraEduLatencyLevel.
    userPropertiesUser properties customized by the developer. For details, see How can I set user properties?

    AgoraEduEvent


    _6
    public enum AgoraEduEvent {
    _6
    AgoraEduEventFailed(0),
    _6
    AgoraEduEventReady(1),
    _6
    AgoraEduEventDestroyed(2),
    _6
    AgoraEduEventForbidden(3);
    _6
    }

    Classroom events. Reported in onCallback.

    AttributesDescription
    AgoraEduEventFailed0: The user fails to enter the classroom.
    AgoraEduEventReady1: The classroom is ready.
    AgoraEduEventDestroyed2: The classroom has been destroyed.
    AgoraEduEventForbidden3: The user is forbidden by the Flexible Classroom cloud service and not allowed to enter the classroom.

    AgoraEduRoleType


    _3
    public enum AgoraEduRoleType {
    _3
    AgoraEduRoleTypeStudent(2);
    _3
    }

    The role of the user in the classroom. Set in AgoraEduLaunchConfig.

    AttributesDescription
    AgoraEduRoleTypeStudent2: A student.

    AgoraEduRoomType


    _5
    public enum AgoraEduRoomType {
    _5
    AgoraEduRoomType1V1(0),
    _5
    AgoraEduRoomTypeSmall(4),
    _5
    AgoraEduRoomTypeBig(2);
    _5
    }

    The classroom type. Set in AgoraEduLaunchConfig.

    AttributesDescription
    AgoraEduRoomType1V10: One-to-one Classroom. An online teacher gives an exclusive lesson to only one student.
    AgoraEduRoomTypeBig2: Lecture Hall. A teacher gives an online lesson to multiple students. Students do not send their audio and video by default. There is no upper limit on the number of students. During the class, students can "raise their hands" to apply for speaking up. Once the teacher approves, the student can send their audio and video to interact with the teacher.
    AgoraEduRoomTypeSmall4: Small Classroom. A teacher gives an online lesson to multiple students. Students do not send their audio and video by default. The maximum number of users in a classroom is 500. During the class, the teacher can invite students to speak up "on stage" and have real-time audio and video interactions with the teacher.

    AgoraBoardFitMode


    _4
    public enum AgoraBoardFitMode {
    _4
    Auto,
    _4
    Retain;
    _4
    }

    The PPT display mode on the whiteboard. Set in AgoraEduLaunchConfig.

    ParameterDescription
    Auto(Default) The PPT display mode is fit, which means uniformly scaling the PPT until one of its dimensions fits the boundary.
    RetainIn this mode, if the student manually adjusts the PPT size, the client maintains this size no matter what class the student joins.

    StreamState


    _4
    data class StreamState (
    _4
    var videoState:Int,
    _4
    var audioState:Int
    _4
    )

    Controls whether students automatically send audio or video streams after they go onto the "stage". Set in AgoraEduLaunchConfig.

    ParameterDescription
    videoStateWhether to send the video stream:
  • 0: (Default) Do not send the video stream.
  • 1: Send the video stream.
  • audioStateWhether to send the audio stream:
  • 0: (Default) Do not send the audio stream.
  • 1: Send the audio stream.
  • AgoraEduLatencyLevel


    _4
    enum class AgoraEduLatencyLevel(val value: Int) {
    _4
    AgoraEduLatencyLevelLow(1),
    _4
    AgoraEduLatencyLevelUltraLow(2);
    _4
    }

    The latency level of an audience member. Set in AgoraEduLaunchConfig.

    ParameterDescription
    AgoraEduLatencyLevelLowLow latency. The latency from the sender to the receiver is 1500 ms to 2000 ms.
    AgoraEduLatencyLevelUltraLow(Default) Ultra-low latency. The latency from the sender to the receiver is 400 ms to 800 ms.

    AgoraEduMediaOptions


    _1
    class AgoraEduMediaOptions(val encryptionConfigs: AgoraEduMediaEncryptionConfigs?)

    Media options. Set in AgoraEduLaunchConfig.

    ParameterDescription
    encryptionConfigThe media stream encryption configuration. See AgoraEduMediaEncryptionConfig for details.

    AgoraEduMediaEncryptionConfig


    _4
    data class AgoraEduMediaEncryptionConfigs(
    _4
    val encryptionKey: String?,
    _4
    val encryptionMode: Int
    _4
    )

    The media stream encryption configuration. Used in AgoraEduMediaOptions.

    ParameterDescription
    modeThe encryption mode. See AgoraEduEncryptMode.
    keyThe encryption key.

    AgoraEduEncryptMode


    _9
    enum class AgoraEduEncryptMode(val value: Int) {
    _9
    NONE(0),
    _9
    AES_128_XTS(1),
    _9
    AES_128_ECB(2),
    _9
    AES_256_XTS(3),
    _9
    SM4_128_ECB(4),
    _9
    AES_128_GCM(5),
    _9
    AES_256_GCM(6);
    _9
    }

    The media stream encryption configuration. See AgoraEduMediaEncryptionConfig for details.

    ParameterDescription
    NONENo encryption.
    AES_128_XTS128-bit AES encryption, XTS mode.
    AES_128_ECB128-bit AES encryption, ECB mode.
    AES_256_XTS256-bit AES encryption, XTS mode.
    SM4_128_ECB128-bit ECB encryption, SM4 mode.
    AES_128_GCM128-bit AES encryption, GCM mode.
    AES_256_GCM256-bit AES encryption, GCM mode.

    AgoraEduCourseware


    _7
    data class AgoraEduCourseware(
    _7
    val resourceName: String?,
    _7
    val scenePath: String?,
    _7
    val scenes: List<SceneInfo>?,
    _7
    val resourceUrl: String?
    _7
    ) {
    _7
    }

    The courseware pre-download configuration. Used in configCoursewares.

    AttributesDescription
    resourceNameThe file name.
    scenePathThe local path for storing the file. Agora recommends setting this parameter as the combination of resourceName and name of the first SceneInfo object in scenes, such as, resourceName + "/" + sceneInfos.get(0).name.
    scenesA list of converted file pages, an array of SceneInfo objects. Flexible Classroom automatically converts files with the suffixes of "ppt", "pptx", "doc", "docx", and "pdf" to formats that can be displayed on the whiteboard in the classroom and then display the file on the whiteboard in pages. Each SceneInfo object represents one page.
    resourceUrlThe URL address of the file, such as "https://convertcdn.netless.link/dynamicConvert/{taskUuid}.zip".

    SceneInfo


    _5
    public class SceneInfo {
    _5
    private int componentCount;
    _5
    private Ppt ppt;
    _5
    private String name;
    _5
    }

    The detailed information of a page. Set in AgoraEduCourseware.

    AttributesDescription
    componentCountThe number of pages.
    pptThe detailed information of a converted page. See Ppt.
    nameThe page name.

    Ppt


    _5
    public class Ppt {
    _5
    private String src;
    _5
    private double width;
    _5
    private double height;
    _5
    }

    The detailed information of a page displayed on the whiteboard. Set in SceneInfo.

    AttributesDescription
    srcThe URL address of the converted page.
    widthThe width (pixel) of the page.
    heightThe height (pixel) of the page.

    AgoraEduRegion


    _7
    object AgoraEduRegion {
    _7
    const val default = "CN"
    _7
    const val cn = "CN"
    _7
    const val na = "NA"
    _7
    const val eu = "EU"
    _7
    const val ap = "AP"
    _7
    }

    Regions.

    AttributesDescription
    CNMainland China.
    NANorth America.
    EUEurope.
    APAsia Pacific.

    EduVideoEncoderConfig


    _7
    data class EduVideoEncoderConfig(
    _7
    var videoDimensionWidth: Int = 320,
    _7
    var videoDimensionHeight: Int = 240,
    _7
    var frameRate: Int = 15,
    _7
    var bitrate: Int = 200,
    _7
    var mirrorMode: Int = EduMirrorMode.AUTO.value
    _7
    )

    The video encoder configuration. Used in AgoraEduLaunchConfig.

    • In the Small Classroom scenario, the default resolution is 120p (160*120).
    • In the One-to-one Classroom and Lecture Hall scenarios, the default resolution is 240p (320*240).
    ParameterDescription
    widthWidth (pixel) of the video frame.
    heightHeight (pixel) of the video frame.
    frameRateThe frame rate (fps) of the video. The default value is 15.
    bitrateThe bitrate (Kbps) of the video. The default value is 200.
    mirrorModeVideo mirror modes. See EduMirrorMode.

    EduMirrorMode


    _5
    enum class EduMirrorMode(val value: Int) {
    _5
    AUTO(0),
    _5
    ENABLED(1),
    _5
    DISABLED(2)
    _5
    }

    Whether to enable mirror mode. Used in EduVideoEncoderConfig.

    ParameterDescription
    AUTOThe SDK disables mirror mode by default.
    ENABLEDEnable mirror mode.
    DISABLEDDisable mirror mode.

    Page Content