diff --git a/README.md b/README.md
index 03f536454..d2c6e8ba8 100644
--- a/README.md
+++ b/README.md
@@ -221,7 +221,9 @@ room.localParticipant.setScreenShareEnabled(true);
#### Android
-On Android, you would have to define a foreground service in your AndroidManifest.xml.
+On Android, you will have to use a [media projection foreground service](https://developer.android.com/develop/background-work/services/fg-service-types#media-projection).
+
+In our example, we use the `flutter_background` package to handle this. In the app's AndroidManifest.xml file, declare the service with the appropriate types and permissions as following:
```xml title="AndroidManifest.xml"
@@ -239,6 +241,8 @@ On Android, you would have to define a foreground service in your AndroidManifes
```
+Before starting the background service and enabling screen share, you **must** call `Helper.requestCapturePermission()` from `flutter_webrtc`, and only proceed if it returns true.
+
#### iOS
On iOS, a broadcast extension is needed in order to capture screen content from
diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle
index a69c17d72..36393eda9 100644
--- a/example/android/app/build.gradle
+++ b/example/android/app/build.gradle
@@ -41,7 +41,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "io.livekit.example"
minSdkVersion 21
- targetSdkVersion 31
+ targetSdkVersion 34
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
diff --git a/example/lib/widgets/controls.dart b/example/lib/widgets/controls.dart
index 761b16f8f..db0698d83 100644
--- a/example/lib/widgets/controls.dart
+++ b/example/lib/widgets/controls.dart
@@ -156,6 +156,11 @@ class _ControlsWidgetState extends State {
}
if (lkPlatformIs(PlatformType.android)) {
// Android specific
+ bool hasCapturePermission = await Helper.requestCapturePermission();
+ if (!hasCapturePermission) {
+ return;
+ }
+
requestBackgroundPermission([bool isRetry = false]) async {
// Required for android screenshare.
try {
diff --git a/pubspec.lock b/pubspec.lock
index 60f1615b6..b185a6b79 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -228,10 +228,10 @@ packages:
dependency: "direct main"
description:
name: flutter_webrtc
- sha256: fd5f115a08dcdc00b988bea3003c956f1b60a78a61d899cbddfb44f5d0e44d4a
+ sha256: a09adf01e8b760a9ca6418323786f51417fb75986f210513e83d4753686795f0
url: "https://pub.dev"
source: hosted
- version: "0.10.8"
+ version: "0.11.1"
glob:
dependency: transitive
description: