# Enable and disable the whiteboard (/en/realtime-media/flexible-classroom/build/customize-the-ui-and-plugins/disable-whiteboard-module/android)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

The whiteboard module in Flexible Classroom is implemented based on `AgoraWidget`. You can turn the whiteboard module on or off in the classroom by setting the widget state as active or inactive.

After disabling the whiteboard module, drawing tools including pencil, text box, shape, and eraser will no longer be available and users cannot upload, delete, or display class files on the whiteboard. Other features that do not rely on the whiteboard, such as uploading or deleting class files, pop-up quiz, countdown timer, and screen sharing will not be affected.

      
    ## Android [#android]

    The component corresponding to the Whiteboard widget is named `AgoraEduWhiteBoardComponent`, and the widget ID can be obtained using `AgoraWidgetDefaultId.WhiteBoard.id`. Use this component to turn the Whiteboard on or off.

    To enable or disable the Whiteboard, you monitor the status changes of the Whiteboard caused by the teacher client and adjust the UI accordingly. See `initView()` in the file `AgoraEduUIKit/src/main/java/com/agora/edu/component/whiteboard/AgoraEduWhiteBoardComponent.kt` for the logic of registering observers, listening for active states, and creating or destroying Whiteboard components in the methods.

    If you want to open and close the Whiteboard by yourself, you can refer to the following code examples:

    * To turn on the Whiteboard, add the following code to the file where the button to open the Whiteboard is located:

      ```java
      val info = AgoraWidgetRoomPropsUpdateReq(state = 1)
      eduContext?.widgetContext()?.setWidgetActive(AgoraWidgetDefaultId.WhiteBoard.id, info)
      ```

    * To close the Whiteboard, add the following code to the file where the button to close the Whiteboard is located:

      ```java
      eduContext?.widgetContext()?.setWidgetInActive(AgoraWidgetDefaultId.WhiteBoard.id)
      ```

    * To register an observer, use the following code:

      ```java
      eduContext?.widgetContext()?.addWidgetActiveObserver(widgetActiveObserver, AgoraWidgetDefaultId.LargeWindow.id)
      ```

    * To monitor the status of the widget, use the following code:

      ```java
      private val widgetActiveObserver = object : AgoraWidgetActiveObserver {
          override fun onWidgetActive(widgetId: String) {
              // The Whiteboard has been created, here is the child thread
              if (widgetId == AgoraWidgetDefaultId.WhiteBoard.id) {

              }
          }

          override fun onWidgetInActive(widgetId: String) {
              // The Whiteboard has been removed, here is the child thread
              if (widgetId == AgoraWidgetDefaultId.WhiteBoard.id) {

              }
          }
      }
      ```

    ## API Reference [#api-reference]

    ### AgoraWidgetContext [#agorawidgetcontext]

    #### create [#create]

    ```kotlin
    fun create(config: AgoraWidgetConfig): AgoraBaseWidget?
    ```

    Create a Widget object instance.

    Parameter:

    * config: The configuration information of this Widget object.

    Return: Widget instance, empty means creation failed.

    #### getWidgetConfig [#getwidgetconfig]

    ```kotlin
    fun getWidgetConfig(widgetId: String): AgoraWidgetConfig?
    ```

    Get the configuration information of a registered Widget.

    Parameter:

    * widgetId: The unique identifier of the Widget.

    Return: An `AgoraWidgetConfig` object.

    #### setWidgetActive [#setwidgetactive]

    ```kotlin
    fun setWidgetActive(widgetId: String, ownerUserUuid: String? = null,
                        roomProperties: Map<String, Any>? = null,
                        callback: EduContextCallback<Unit>? = null)
    ```

    Activate a Widget.

    Parameter:

    * widgetId: Widget's unique identifier.
    * ownerUserUuid: UserUuid of the user who owns the currently activated Widget.
    * roomProperties: Initialized room properties.
    * callback: Callback listener for activation operation.

    Return: After the operation is successful, you will receive the callback of `AgoraWidgetActiveObserver.onWidgetActive`.

    #### setWidgetInActive [#setwidgetinactive]

    ```kotlin
    fun setWidgetInActive(widgetId: String, isRemove: Boolean = false, callback: EduContextCallback<Unit>? = null)
    ```

    Unregister the specified Widget.

    Parameter:

    * widgetId: Widget's unique identifier.
    * isRemove: Whether to completely delete all information of this Widget in the current classroom:
      * true: Delete completely. All information under `roomProperties.widgets.'widgetId'` and `userProperties.widgets.'widgetId'` will be removed.
      * false: Only set `roomProperties.widgets.'widgetId'.state` to '0', that is, set the current Widget as inactive. No matter what this value is passed, it will receive the callback of `AgoraWidgetActiveObserver.onWidgetInActive`.
    * callback: Callback listener for logout operation.

    #### getWidgetActive [#getwidgetactive]

    ```kotlin
    fun getWidgetActive(widgetId: String): Boolean
    ```

    Get the activation state of a Widget.

    Parameter:

    * widgetId: Widget's unique identifier.

    Return: Boolean indicating the activation state of a Widget.

    #### getAllWidgetActive [#getallwidgetactive]

    ```kotlin
    fun getAllWidgetActive(): Map<String, Boolean>
    ```

    Get the activation status of all registered Widgets.

    Return: Map holding the activation statuses of all registered Widgets.

    #### addWidgetActiveObserver [#addwidgetactiveobserver]

    ```kotlin
    fun addWidgetActiveObserver(observer: AgoraWidgetActiveObserver, widgetId: String)
    ```

    Add an `AgoraWidgetActiveObserver` listener to monitor whether this Widget is active.

    Parameter:

    * observer: `AgoraWidgetActiveObserver` listener to add.
    * widgetId: Widget's unique identifier.

    #### removeWidgetActiveObserver [#removewidgetactiveobserver]

    ```kotlin
    fun removeWidgetActiveObserver(observer: AgoraWidgetActiveObserver, widgetId: String)
    ```

    Delete an `AgoraWidgetActiveObserver` listener.

    Parameter:

    * observer: `AgoraWidgetActiveObserver` listener to remove.
    * widgetId: Widget's unique identifier.

    #### addWidgetMessageObserver [#addwidgetmessageobserver]

    ```kotlin
    fun addWidgetMessageObserver(observer: AgoraWidgetMessageObserver, widgetId: String)
    ```

    Add an `AgoraWidgetMessageObserver` listener to listen to all messages sent by this Widget.

    Parameter:

    * observer: `AgoraWidgetMessageObserver` listener to add.
    * widgetId: Widget's unique identifier.

    #### removeWidgetMessageObserver [#removewidgetmessageobserver]

    ```kotlin
    fun removeWidgetMessageObserver(observer: AgoraWidgetMessageObserver, widgetId: String)
    ```

    Delete an `AgoraWidgetMessageObserver` listener.

    Parameter:

    * observer: `AgoraWidgetMessageObserver` listener to remove.
    * widgetId: Widget's unique identifier.

    #### sendMessageToWidget [#sendmessagetowidget]

    ```kotlin
    fun sendMessageToWidget(msg: String, widgetId: String)
    ```

    Send a message to a Widget.

    Parameter:

    * msg: Message to send.
    * widgetId: Widget's unique identifier.

    
  
      
  
      
  
      
  
