Table of Contents

To support Screen-Sharing in the Room, you need to enable Screen-Sharing during Room Creation by setting: { "screen_share": true; }) in the JSON Payload. To receive Shared Screen, you need to subscribe to the Screen-Share Stream ID# 101 and play it on the Video Player.

Note: If you have Android 11 (API level 30) or higher, then you must create a foreground service and access the camera or microphone in the foreground service. Declare the camera or microphone foreground service types, respectively, as attributes of your <service> component. [ Read More… ]

Start Screen Sharing

The EnxRoom.startScreenShare() method is used to create a Screen-Sharing Stream @ 6fps to publish in the Room. Screen Sharing continues even when the Application runs in the background.

Class: EnxRoom

Observer: public void setScreenShareObserver(EnxScreenShareObserver-Object)

Method: public void startScreenShare()


onScreenSharedStarted – Notification to everyone in the Room when Screen-Sharing starts.

// Initiate Screen Share Observer to receive Callbacks

// Start Screen Share

// A new Screen Share Stream is available, receive Information
public void onScreenSharedStarted(EnxStream enxStream) {
	// Get EnxPlayerView from ensStream
	// And add to View

Stop Screen Sharing

The EnxRoom.stopScreenShare() method is used to stop the ongoing Screen-Sharing.

Class: EnxRoom

Method: public void stopScreenShare()


onScreenSharedStopped – Notification to everyone in the Room when Screen-Sharing stops.

room.stopScreenShare(); // Stop Screen Share

// Screen Share has stopped. Receive Information
public void onScreenSharedStopped(EnxStream enxStream){
// And remove View from yourView

Error Codes / Exceptions:

5107Repeated startScreenShare() call made while previous request is in process.
1170Screen-Sharing not supported in your subscription.

Force Stop other’s Screen Sharing

Availability: Android SDK 2.1.2+

If moderator wishes to force stop any ongoing Screen Share by other user in the Room, he can do so by using EnxRoom.stopAllSharing() method. Note, this is Moderator exclusive feature, can’t be executed from Participant’s end point.

This method also force stops any ongoing Canvas Streaming.

Class: EnxRoom

Observer: ACK CallBack

Method: public void stopAllSharing()


onStopAllSharingACK – Notification to everyone in the Room when Screen-Sharing stops.

EnxRoom.stopAllSharing()     // Force Stop the Shared Screen

// Notification to all when share stops
public void onStopAllSharingACK(JSONObject jsonObject) {
	// Code here... to handle your UI

Implementing a Foreground Service

The implementation part is quite similar to that of a service. Let’s check the step-by-step procedure for doing this.

  1. Create a foreground service
  2. Add permission in manifest
  3. Register foreground service in manifest

Create a Foreground Service

public class ForegroundService extends Service {
public static final String CHANNEL_ID = "ForegroundServiceChannel";
int NOTIFICATION_ID = 121412;
public NotificationManager notificationManager;
public void onCreate() {

public int onStartCommand(Intent intent, int flags, int startId) {
if (intent != null) {
if (intent.getAction().equals("ACTION_START")) {
}else {
public void onDestroy() {
public IBinder onBind(Intent intent) {
return null;
private void showOnGoingCall() {
String app_Name = getResources().getString(R.string.app_name);
Intent notificationIntent = new Intent(this, VideoConferenceActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
String CHANNEL_ID = getResources().getString(R.string.app_name);
Notification notification;
if (Build.VERSION.SDK_INT >= 26) {
NotificationChannel channel = new NotificationChannel(CHANNEL_ID, "Sync Service", NotificationManager.IMPORTANCE_HIGH);
channel.setDescription("Service Name");
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

notification = new NotificationCompat.Builder(this, CHANNEL_ID)
.setContentText("Ongoing call")
} else {
notification = new Notification.Builder(this)
.setContentTitle("Project Name")
.setContentText("Ongoing call")
notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
startForeground(NOTIFICATION_ID, notification);
private void stopForegroundService() {

Add Permission in Manifest

We need to request foreground service permission for Android 9 (API level 28) or higher. We need to specify the permission below in our manifest file:

<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

Register Foreground Service in Manifest

<service    android:name=".activity.ForegroundService"    android:enabled="true"    android:foregroundServiceType="mediaProjection"    android:exported="true" />Call Foreground Service in VideoConferenceActivity public void startService() {        Intent serviceIntent = new Intent(VideoConferenceActivity.this, ForegroundService.class);        serviceIntent.setAction("ACTION_START");//        serviceIntent.putExtra("inputExtra", "Foreground Service Example in Android");        ContextCompat.startForegroundService(VideoConferenceActivity.this, serviceIntent);    }    public void stopService() {        Intent serviceIntent = new Intent(VideoConferenceActivity.this, ForegroundService.class);        serviceIntent.setAction("ACTION_STOP");        stopService(serviceIntent);//        ContextCompat.startForegroundService(getActivity(), serviceIntent);    } stopService() call in onDestroy method and startService() call in onStart method