Share


Contents

1. Share Content

2. Share Screen and View

3. Customize Share Menu

1. Share Content

1.1 Handle Share Event

Use the following code to enable a meeting handler for the share active user event:

@Override
public void onShareActiveUser(long userId) {
     ...
}

1.2 View Content

If the User ID is not myself and not -1 then try to add a share video unit to your meeting UI. Then subscribe to the user’s share content.

InMeetingShareController mInMeetingShareController = mInMeetingService.getInMeetingShareController();

if (mInMeetingShareController.isOtherSharing()) {
  //your other ui action
  ...
  mDefaultVideoViewMgr.addShareVideoUnit(shareUserId, /*yourShareRenderInfo*/);
  //your other ui action
  ...
}

1.3 Stop Viewing Shared Content

If you would like to stop viewing shared content when the User ID is myself or -1, you can try to remove the share video unit.

if (!mInMeetingShareController.isOtherSharing()) {
  //your other ui action
  ...
  mDefaultVideoViewMgr.removeShareVideoUnit();
  //your other ui action
  ...
}

2. Share Screen and View

Screen sharing

Screen sharing is only supported on Android 5.0 and above.

2.1 Share Screen

  1. Ask for screen capture permission from the Android system.

For more information on how to attain permission from the Android system please refer to this reference document.

  1. Call the InMeetingShareController interface to start a screen share session:
if (Build.VERSION.SDK_INT >= 24 && ! Settings.canDrawOverlays(this)) {
    
  Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
            Uri.parse("package:" + getPackageName()));
    
  mScreenInfoData = data;
  startActivityForResult(intent,REQUEST_SYSTEM_ALERT_WINDOW);
  
} else {
  
    mInMeetingShareController.startShareScreenSession(intentData);
		//intenData : obtain it from step 1
}
  1. Handle the share event and distribute screen content:
@Override
public void onShareActiveUser(long userId) {
    ...
    if (mInMeetingService.isMyself(userId)) {
        if (mInMeetingShareController.isSharingOut()) {
            if (mInMeetingShareController.isSharingScreen()) {
                mInMeetingShareController.startShareScreenContent();
            }
        }
    }
}
  1. Call the InMeetingShareController interface to stop screen sharing:
if (mInMeetingShareController.isSharingScreen()) {
   mInMeetingShareController.stopShareScreen();
}

2.2 Distribute the Shared View

  1. Add a MobileRTCShareView function to your meeting layout:
<us.zoom.sdk.MobileRTCShareView
   android:id="@+id/sharingView"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:visibility="gone" />
  1. Enable the InMeetingShareController interface to start a share view session:
boolean success = mInMeetingShareController.startShareViewSession();

if (!success) {
   Log.i(TAG, "startShare is failed");
   return;
}

mShareView.setVisibility(View.VISIBLE);
//Set a bitmap to share a image
mShareView.setShareImageBitmap(Bitmap);
//Set a url to share a webview
mShareView.setShareWebview(Url);
  1. Handle the share event and distribute share content:
@Override
public void onShareActiveUser(long userId) {
    ...
    if (mInMeetingService.isMyself(userId)) {
        if (mInMeetingShareController.isSharingOut()) {
            if (!mInMeetingShareController.isSharingScreen()) {
                mInMeetingShareController.startShareViewContent(mShareView);
            }
        }
    }
}
  1. Call the InMeetingShareController interface to stop screen sharing:
if(mShareView != null) {
   mInMeetingShareController.stopShareView();
}

3. Customize share menu

You can customize the share menu and change the behavior of each menu item by implementing a showShareActionPopupWindow method:

public void showShareActionPopupWindow() {

    final SimpleMenuAdapter menuAdapter = new SimpleMenuAdapter(activity);

    if (Build.VERSION.SDK_INT >= 21) {
        menuAdapter.addItem(new SimpleMenuItem(MENU_SHARE_SCREEN, "Screen"));
    }
    menuAdapter.addItem(new SimpleMenuItem(MENU_SHARE_IMAGE, "Image"));
    menuAdapter.addItem(new SimpleMenuItem(MENU_SHARE_WEBVIEW, "Web url"));
    menuAdapter.addItem(new SimpleMenuItem(MENU_WHITE_BOARD, "WhiteBoard"));

    View popupWindowLayout = LayoutInflater.from(activity).inflate(R.layout.popupwindow, null);

    ListView shareActions = (ListView) popupWindowLayout.findViewById(R.id.actionListView);
    final PopupWindow window = new PopupWindow(popupWindowLayout, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    window.setBackgroundDrawable(activity.getResources().getDrawable(R.drawable.bg_transparent));
    shareActions.setAdapter(menuAdapter);

    shareActions.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (mInMeetingShareController.isOtherSharing()) {
                showOtherSharingTip();
                window.dismiss();
                return;
            }

            SimpleMenuItem item = (SimpleMenuItem) menuAdapter.getItem(position);
            if (item.getAction() == MENU_SHARE_WEBVIEW) {
                startShareWebUrl();
            } else if (item.getAction() == MENU_SHARE_IMAGE) {
                startShareImage();
            } else if (item.getAction() == MENU_SHARE_SCREEN) {
                askScreenSharePermission();
            } else if (item.getAction() == MENU_WHITE_BOARD) {
                startShareWhiteBoard();
            }
            window.dismiss();
        }
    });

    window.setFocusable(true);
    window.setOutsideTouchable(true);
    window.update();
    if (null != callBack) {
        callBack.showShareMenu(window);
    }
}