# Interact with screen sharing

<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

> The code on this page works with either the **default UI** or the **custom UI**.

Users in a meeting can share the contents of their screens to the rest of the meeting,
and view content in real time shared by other users. To manage screen sharing
functionality, use the `InMeetingShareController`.

```kotlin
val screenShareController = ZoomSDK.getInstance().inMeetingService.inMeetingShareController
```

```java
InMeetingShareController screenShareController = ZoomSDK.getInstance().getInMeetingService().getInMeetingShareController();
```

## Share your screen

Check whether you can start sharing before calling the `startShareScreenSession` method.

```kotlin
val reasonType =
            ZoomSDK.getInstance().inMeetingService.inMeetingShareController.canStartShare()
if (reasonType != CannotShareReasonType.CannotShareReasonType_None) {
// Not able to start sharing
}
```

```java
CannotShareReasonType reasonType = ZoomSDK.getInstance().getInMeetingService().getInMeetingShareController().canStartShare();
if (reasonType != CannotShareReasonType.CannotShareReasonType_None) {
    // Not able to start sharing
}
```

To share your screen, choose the share type that best fits your use case.

-   **Share the whole screen** - Capture the whole screen from the device that is sharing.
-   **Share a single view** - Define a `MobileRTCShareView` surrounding the content you want to share.

To know when a user's share status changes, use the `onSharingStatus` callback.

```kotlin
val shareListener = object : InMeetingShareListener {
    override fun onSharingStatus(status: SharingStatus?, userId: Long) {
        // Respond to changes in share status here
    }

    ...
}

screenShareController.addListener(shareListener)
```

```java
InMeetingShareController.InMeetingShareListener shareListener = new InMeetingShareController.InMeetingShareListener() {
    @Override
    public void onSharingStatus(SharingStatus sharingStatus, long userId) {
        // Respond to changes in share status here
    }

    ...
};

screenShareController.addListener(shareListener);
```

Sharing the whole screen requires more setup, since the Android system relies on an `Intent`
from the `MediaProjectionManager`. To request permission from the end user to capture their
screen's contents, create this `Intent` and pass it into the SDK. You also need `ACTION_MANAGE_OVERLAY_PERMISSION`
for displaying the sharing tool bar.

```kotlin
val mediaProjectionManager = activity.getSystemService(Context.MEDIA_PROJECTION_SERVICE) as MediaProjectionManager
val mediaProjectionIntent = mediaProjectionManager.createScreenCaptureIntent()
screenShareController.startShareScreenSession(mediaProjectionIntent)
```

```java
MediaProjectionManager mediaProjectionManager = activity.getSystemService(Context.MEDIA_PROJECTION_SERVICE);
Intent mediaProjectionIntent = mediaProjectionManager.createScreenCaptureIntent();
screenShareController.startShareScreenSession(mediaProjectionIntent);
```

## View another user's screen share

Use a `MobileRTCVideoView` instance to subscribe to a user's share feed. Once another
user's share is visible as indicated by the `Sharing_View_Other_Sharing` status in
`onSharingStatus`, render the screen share with `addShareVideoUnit`.

```kotlin
val renderInfo = MobileRTCRenderInfo(0, 0, 100, 100) // Sample render info
videoView.videoViewManager.addShareVideoUnit(userId, renderInfo)
```

```java
MobileRTCRenderInfo renderInfo = new MobileRTCRenderInfo(0, 0, 100, 100); // Sample render info
videoView.getVideoViewManager().addShareVideoUnit(userId, renderInfo);
```

Unsubscribe from the share data when a user stops their share, when
`Sharing_Other_Share_End` is received in `onSharingStatus`.

```kotlin
videoView.videoViewManager.removeShareVideoUnit()
```

```java
videoView.getVideoViewManager().removeShareVideoUnit();
```

## Manage share settings

To control most of the in-meeting share settings, use `MeetingSettingsHelper`.

```kotlin
val meetingSettingsHelper = ZoomSDK.getInstance().meetingSettingsHelper
```

```java
MeetingSettingsHelper meetingSettingsHelper = ZoomSDK.getInstance().getMeetingSettingsHelper();
```

To toggle whether a green border will surround the content being shared by this
device, use `enableGreenBorderForShareScreen`.

```kotlin
meetingSettingsHelper.enableGreenBorderForShareScreen(true)
```

```java
meetingSettingsHelper.enableGreenBorderForShareScreen(true);
```

When annotation is enabled, the default annotation toolbar is displayed. To hide or replace
the default annotation toolbar and replace it with a custom annotation toolbar, use
`hideAnnotationInScreenShareToolbar` to disable the annotation UI when you start
sharing your screen.

```kotlin
meetingSettingsHelper.hideAnnotationInScreenShareToolbar(true)
```

```java
meetingSettingsHelper.hideAnnotationInScreenShareToolbar(true);
```

The default overlay has a button that the end user can select to end their screen share. Toggle this
with `hideStopShareInScreenShareToolbar`.

```kotlin
meetingSettingsHelper.hideStopShareInScreenShareToolbar(true)
```

```java
meetingSettingsHelper.hideStopShareInScreenShareToolbar(true);
```

In addition to the toolbar overlay, the SDK shows a video tile with the active speaker when a
share starts. To toggle this view's visibility, use `setNoVideoTileOnShareScreenEnabled`.

```kotlin
meetingSettingsHelper.isNoVideoTileOnShareScreenEnabled = true
```

```java
meetingSettingsHelper.setNoVideoTileOnShareScreenEnabled(true);
```

To toggle whether your video will automatically turn off when you start sharing your screen,
use `setVideoOnWhenMyShare`.

```kotlin
meetingSettingsHelper.setVideoOnWhenMyShare(true)
```

```java
meetingSettingsHelper.setVideoOnWhenMyShare(true);
```

---
