Embed a custom plugin
ExtApp enables developers to develop a custom plugin, such as a countdown plugin or a dice, and embed the plugin in the flexible classroom. Plugins implemented by ExtApp can be regarded as an independent application with its own life cycle and data management, but they also connect with the Agora Classroom SDK. Developers can customize the user interfaces of the plugins, pass custom data to the Agora Classroom SDK, and also listen for data change from the Agora Classroom SDK.
The source code of ExtApp is in the extapp
directory the CloudClass-Android repository on GitHub (Branch release/apaas/1.1.5.1).
This page introduces the procedure of using ExtApp to develop and embed a custom plugin in the flexible classroom.
Procedure
1. Implement a plugin
First, inherit the io.agora.extension.AgoraExtAppBase
class to implement a custom plugin in your app.
AgoraExtAppBase
includes the following methods and callbacks:
Method
updateProperties
Update properties. Other plugins receive the onPropertyUpdated
callback to get the new properties.
Parameter | Description |
---|---|
properties | The property map. |
cause | The reason map. |
callback | Asynchronously check whether this method call is successful through AgoraExtAppCallback . |
deleteProperties
Delete properties. Other plugins receive the onPropertyUpdated
callback to get the new properties.
Parameter | Description |
---|---|
properties | The property map. |
cause | The reason map. |
callback | Asynchronously check whether this method call is successful through AgoraExtAppCallback . |
unload
Remove the plugin. A successful method call triggers the onExtAppUnloaded
callback.
getLocalUserInfo
Get the current user information.
getRoomInfo
Get the current classroom information.
getProperties
Get the current property list.
Callback
onExtAppLoaded
This callback is triggered after the plugin is initialized and before the view is added to the container.
Parameter | Description |
---|---|
context | The android context. |
onCreateView
Occurs when the view is created.
Occurs when the properties of the container are updated.
Parameter | Description |
---|---|
properties | The property map. |
cause | The reason map. |
callback | Asynchronously check whether this method call is successful through AgoraExtAppCallback . |
onExtAppUnloaded
Occurs after the plugin is closed and before the view is removed from the container.
2. Register the plugin to the Agora Classroom SDK
To register the plugin in the Agora Classroom SDK, call AgoraEduSDK.registerExtApp
.
The following sample code demonstrates how to register the countdown plugin CountDownExtApp.
3. Use the plugin in the flexible classroom
By default, the icon of the registered plugin is displayed in the whiteboard toolbar in the flexible classroom.
If you want to customize an entry for the plugin in the flexible classroom, you can edit the AgoraUI1v1Container.kt
, AgoraUILargeClassContainer.kt,
and AgoraUISmallClassContainer.kt
files under the agoraui/src/main/kotlin/io/agora/uikit/impl/container
path. Then call the following methods when the user clicks on the plugin icon.