Table of Contents

How to add screen sharing to your Android app with Sendbird Calls

How to add screen sharing to your Android app with Sendbird Calls

Walter Rodriguez
Tutorial Type: Reading Time: 20 minutes Building Time: 2 hours

This guide was created as a two part guide. In Part 1 we showed you how you can implement calls with video functionality. In this Part 2 we will be showing you how to implement a simple screen sharing functionality. 


    • For the simplicity of this tutorial, we will use targetSdkVersion 28 in our gradle file so we don’t have to implement a service required by Google if you work with version 29 or older.
    • This guide assumes that you have already completed the Part 1 of this guide, and the subsequent guide will build onto the Part 1.

Step 1: Modifying Permissions

In the first part, we added all the permissions we would need to be able to make a successful video call. Now in Part 2 we need to modify the original manifest with an additional permission. The FOREGROUND_SERVICE permission allows for screen share. 

Next, down in the application tag <application>…</application>, add the following to your Manifest for defining a foreground service:

Step 2. Modifying the UI

Now that we have added the appropriate permissions/services to the manifest, let’s modify the activity_main.xml layout we created in part 1. For this we will want to add a button to allow for sharing our screen.

Layout for our unique screen

After you have added the button, your xml will look like the above.

Step 3. Modifying the implementation

Now we need to modify our implementation. First go to your In the list of global variables we created in Part 1 for both Buttons, and Video Views, add another Button for Share Screen. 

Then add a global variable for requesting permission to do screen recording (set any number higher than zero)

Now in our initElementsOnScreen Method you will want to initialize the butShareScreen and set a onClickListener. 


Share your screen

To share your screen, Android uses the Media Projector Manager. You need to ask for a new permission to your user to do this.

As mentioned before, if your targetSdkVersion is 29 or higher, you will need to implement a Foreground Service (as per Android request). For the sake of simplicity, we will use version 28.

When you click the Share Screen button on screen, the method startScreenShare()will be executed.

This function will ask for MediaProjectionManager permissions to the user.

Asking permissions to record (and share) the screen

Once the user accepts, onActivityResult(…) will be invoked automatically:

Our final call is to the startScreenShare(…) method from Sendbird Calls. This will do all the work for us.

Stop screen sharing

To stop sharing your screen you just need to invoke the stopScreenShare method from our global mCurrentCall.

Make sure you first check for a valid object. The CompletionHandler handler will be called once the screen share process is done. Continue with your code with or without errors. For the sake of this guide, we opted to not add a UI element for ending the screen sharing in lieu of showing the implementation for it. 


Now we have fully completed this tutorial. In Part 1 we implemented the functionality for making calls, and now in part 2 we have added the functionality for sharing your screen.

Please feel free to check out the below resources for the full source code, and related documentation!

Resources & documentation

Check the full source, clone and download.

Also check our official documentation and sample code.