Overview
This article provides step-by-step instructions for resolving screen sharing issues in your Android app when using the Agora Video SDK. Users may encounter problems where the local screen is not displayed or is not visible to remote participants during a screen sharing session.
Prerequisites
- Android Studio installed
- Agora Video SDK integrated into your project
- Required permissions set in the AndroidManifest.xml file
Issue Description
Symptoms:
When attempting to start screen sharing via MediaProjection, the local screen may not display or may not be visible to remote participants.
Root Cause:
The issue may stem from missing permissions, incorrect configuration settings, or improper binding of video streams.
Resolution Steps
- Check your AndroidManifest.xml file for the required permissions. Ensure you have included the following lines:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
- Make sure you have obtained user permission for screen sharing before calling the startScreenCapture() method.
- Verify that you configure the video resolution and bitrate correctly before starting screen sharing:
// Set video profile
RtcEngine.setVideoProfile(VideoProfile.STANDARD_RESOLUTION_640x360);
RtcEngine.setVideoBitrate(1000); // Set appropriate bitrate
- Ensure that you have set up the local video view and that it is visible:
RtcEngine.setupLocalVideo(localVideoView);
- Check the remote side to confirm that you are binding the remote UID to a SurfaceView correctly. Use the setupRemoteVideo() method:
RtcEngine.setupRemoteVideo(remoteVideoView, remoteUid);
- Make sure that video streams are not muted. Verify that the video stream is active using:
RtcEngine.muteLocalVideoStream(false); // Ensure local video stream is not muted
Additional Information
Related Issues:
For more information, refer to the following articles:
Keywords for Searchability:
Agora Video SDK, screen sharing, MediaProjection, RtcEngine, AndroidManifest.xml, video stream issues.
Validation and Confirmation
Tested On:
Tested on Agora Video SDK v3.4.1 using Android 13.
Expected Outcome:
After applying these steps, the screen sharing feature should function correctly, displaying the local screen to remote participants.
FAQ
What if I still cannot see the shared screen?
Double-check your permissions and ensure that the Agora SDK is initialized correctly. Review the configuration settings for both local and remote video views.
Do I need to restart the app after making changes?
It is recommended to restart the app to ensure that all configuration changes take effect.