Starts screen capture.

public abstract int startScreenCapture(ScreenCaptureParameters screenCaptureParameters);


There are two ways to start screen sharing, you can choose one according to your needs:
  • Call this method before joining a channel, then call joinChannel [2/2] to join channel and set publishScreenCaptureVideo to true to start screen sharing.
  • Call this method after joining a channel, then call updateChannelMediaOptions and set publishScreenCaptureVideo to true to start screen sharing.
  • On the Android platform, make sure the user has granted the app screen capture permission.
  • Make sure that the Android API level is not earlier than 21, otherwise, the SDK reports error codes ERR_SCREEN_CAPTURE_PERMISSION_DENIED(16) and ERR_SCREEN_CAPTURE_SYSTEM_NOT_SUPPORTED(2).
  • To capture system audio during screen sharing, ensure that the Android API level is not earlier than 29 as well; otherwise, the SDK reports the error code ERR_SCREEN_CAPTURE_SYSTEM_AUDIO_NOT_SUPPORTED(3).
  • On Android 9 and later, to avoid the application being killed by the system after going to the background, Agora recommends you add the foreground service android.permission.FOREGROUND_SERVICE to the /app/Manifests/AndroidManifest.xml file.
  • Due to performance limitations, screen sharing is not supported on Android TV.
  • Due to system limitations, if you are using Huawei phones, do not adjust the video encoding resolution of the screen sharing stream during the screen sharing, or you could experience crashes.
  • Due to system limitations, some Xiaomi devices do not support capturing system audio during screen sharing.
  • To avoid system audio capture failure when screen sharing, Agora recommends that you set the audio application scenario to AUDIO_SCENARIO_GAME_STREAMING by using the setAudioScenario method before joining the channel.


The screen sharing encoding parameters. The default video dimension is 1920 x 1080, that is, 2,073,600 pixels. Agora uses the value of this parameter to calculate the charges. See ScreenCaptureParameters.


  • 0: Success.
  • < 0: Failure.
    • -2: The parameter is null.