Skip to main content

Integrate Flexible Classroom

This page introduces how to add Flexible Classroom into your app.

Understand the tech

The following figure shows the overall technical architecture of Flexible Classroom:

Module introduction

The source code of Flexible Classroom contains the following packages:

  • app: (Optional) This module contains code for the classroom login interface and a client-side token generator, showing how to call APIs to join a flexible classroom. This module is an open-source project available on GitHub and for reference only.
  • Specifications defined for the login interface (such as the length requirement of the user name and the room name and character restrictions) do not apply to all apps. You need to define them according to your own business requirements.
  • The client-side token generator provided by Agora is only for rapid testing. When your app goes live, to ensure security, you must deploy a server-side token generator and generate tokens on your server. For details, see Authenticate Your Users with Tokens.
    • AgoraEduUIKit: (Optional) This module contains code for the classroom UI, showing how to call APIs to aggregate and update UI data. This module is an open-source project available on GitHub. You can develop your own classroom UI based on this module.
    • AgoraClassSDK: (Optional) This module provides methods for configuring the SDK, launching a flexible classroom, and registering ext apps, and provides the activity implementation of each teaching scenario. This module is an open-source project available on GitHub. Agora recommends integrating this module.
    • AgoraEduCore: (Required) The core module of Flexible Classroom. Since v2.0.0, this module is closed-source, and you can import this module only by adding a remote dependency.
    • hyphenate: (Optional) The UI and logic of the chat feature implemented with the Hyphenate IM SDK. If you implement the chat feature on your own, you do not need to import this module.

    Module relations

    • AgoraEduCore is the required core module, and all the other modules depend on it.
    • Both AgoraEduUIKit and AgoraClassSDK depend on AgoraEduCore, and there is no dependency between them.
    • AgoraEduUIKit depends on hyphenate.
    • hyphenate depends on AgoraEduCore.
    • app depends on all other modules.

    Integrate Flexible Classroom through Maven

    If you use the default UI of Flexible Classroom, take the following steps to add remote dependencies and integrate the whole Flexible Classroom through Maven:

    1. Add the following library to your project's build.gradle file:


      _6
      repositories {
      _6
      maven { url 'https://jitpack.io' }
      _6
      google()
      _6
      mavenCentral()
      _6
      maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' }
      _6
      }

    2. Add the following dependencies in the project's build.gradle file to import four modules: AgoraEduUIKit, AgoraClassSDK, AgoraEduCore, and hyphenate:


      _7
      dependencies {
      _7
      ...
      _7
      implementation "io.github.agoraio-community:hyphenate:`{VERSION}`"
      _7
      implementation "io.github.agoraio-community:AgoraEduCore:`{VERSION}`"
      _7
      implementation "io.github.agoraio-community:AgoraEduUIKit:`{VERSION}`"
      _7
      implementation "io.github.agoraio-community:AgoraClassSDK:`{VERSION}`"
      _7
      }

    3. To launch a classroom, call Classroom SDK.setConfig and Classroom SDK.launch. Sample code:


      _30
      fun startClassRoom() {
      _30
      val appId = "" // Pass your App ID
      _30
      val rtmToken = "" // Pass your RTM Token
      _30
      val streamState = AgoraEduStreamState(videoState = 1, audioState = 1)
      _30
      _30
      val config = AgoraEduLaunchConfig(
      _30
      "xiaoming", // The user name
      _30
      "xiaoming2", // The user ID
      _30
      "agoraclass", // The room name
      _30
      "agoraclass4", // The room ID
      _30
      2, // The user role
      _30
      4, // The room type
      _30
      rtmToken,
      _30
      System.currentTimeMillis(), // The class start time
      _30
      1800L, // The class duration
      _30
      AgoraEduRegion.na, // The region
      _30
      null,
      _30
      null,
      _30
      streamState, // Whether students automatically send audio or video streams after they "go onto the stage"
      _30
      AgoraEduLatencyLevel.AgoraEduLatencyLevelUltraLow, // The latency level
      _30
      null,
      _30
      null
      _30
      )
      _30
      _30
      config.appId = appId
      _30
      AgoraClassroomSDK.setConfig(AgoraClassSdkConfig(appId))
      _30
      AgoraClassroomSDK.launch(this, config, AgoraEduLaunchCallback { event ->
      _30
      Log.e(TAG, ":launch-Classroom State:" + event.name)
      _30
      }
      _30
      }

    See also

    Third-party libraries

    No matter which method you choose, the third-party libraries used by Flexible Classroom may conflict with the third-party libraries on which your own project depends. You can use exclude to resolve this conflict or change the version that your project depends on.

    Page Content