Skip to content

Commit d3b60e5

Browse files
authored
[camerax] Add notes about Android permissions (flutter#6741)
Adds notes in the camera/camera and camera/camera_android_cameraX READMEs about the used `WRITE_EXTERNAL_STORAGE` permission used in the plugin and the foreground service permission that is required to specify if you wish to allow image streaming in the background. Fixes flutter#146935 and addresses flutter#131116 (comment).
1 parent 5c60fdc commit d3b60e5

File tree

7 files changed

+38
-4
lines changed

7 files changed

+38
-4
lines changed

packages/camera/camera/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
## NEXT
1+
## 0.11.0+1
22

33
* Updates minimum supported SDK version to Flutter 3.16/Dart 3.2.
4+
* Adds note to `README.md` about allowing image streaming in the background on Android.
45

56
## 0.11.0
67

packages/camera/camera/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ better support for more devices than `camera_android`, but has some limitations;
5050
for more details. If you wish to use the [`camera_android`][4] implementation of the camera plugin
5151
built with Camera2 that lacks these limitations, please follow [these instructions][5].
5252

53+
If you wish to allow image streaming while your app is in the background, there are additional steps required;
54+
please see [these instructions][6] for more details.
55+
5356
### Web integration
5457

5558
For web integration details, see the
@@ -174,3 +177,4 @@ For a more elaborate usage example see [here](https://github.com/flutter/package
174177
[3]: https://pub.dev/packages/camera_android_camerax#limitations
175178
[4]: https://pub.dev/packages/camera_android
176179
[5]: https://pub.dev/packages/camera_android#usage
180+
[6]: https://pub.dev/packages/camera_android_camerax#allowing-image-streaming-in-the-background

packages/camera/camera/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: A Flutter plugin for controlling the camera. Supports previewing
44
Dart.
55
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera
66
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
7-
version: 0.11.0
7+
version: 0.11.0+1
88

99
environment:
1010
sdk: ^3.2.3

packages/camera/camera_android_camerax/CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
## NEXT
1+
## 0.6.5+3
22

33
* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4.
4+
* Adds notes to `README.md` about allowing image streaming in the background and the required
5+
`WRITE_EXTERNAL_STORAGE` permission specified in the plugin to allow writing photos and videos to
6+
files.
47

58
## 0.6.5+2
69

packages/camera/camera_android_camerax/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,28 @@ Calling `startVideoCapturing` with `VideoCaptureOptions` configured with
5151
limitations of the CameraX library and the platform interface, respectively,
5252
and thus, those parameters will silently be ignored.
5353

54+
## What requires Android permissions
55+
56+
### Writing to external storage to save image files
57+
58+
In order to save captured images and videos to files on Android 10 and below, CameraX
59+
requires specifying the `WRITE_EXTERNAL_STORAGE` permission (see [the CameraX documentation][10]).
60+
This is already done in the plugin, so no further action is required on your end. To understand
61+
the implications of specificying this permission, see [the `WRITE_EXTERNAL_STORAGE` documentation][11].
62+
63+
### Allowing image streaming in the background
64+
65+
As of Android 14, to allow for background image streaming, you will need to specify the foreground
66+
[`TYPE_CAMERA`][12] foreground service permission in your app's manifest. Specifically, in
67+
`your_app/android/app/src/main/AndroidManifest.xml` add the following:
68+
69+
```xml
70+
<manifest ...>
71+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CAMERA" />
72+
...
73+
</manifest>
74+
```
75+
5476
## Contributing
5577

5678
For more information on contributing to this plugin, see [`CONTRIBUTING.md`](CONTRIBUTING.md).
@@ -66,4 +88,7 @@ For more information on contributing to this plugin, see [`CONTRIBUTING.md`](CON
6688
[7]: https://developer.android.com/reference/android/hardware/camera2/CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_3
6789
[8]: https://developer.android.com/reference/android/hardware/camera2/CameraMetadata#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED
6890
[9]: https://pub.dev/packages/camera_android#usage
91+
[10]: https://developer.android.com/media/camera/camerax/architecture#permissions
92+
[11]: https://developer.android.com/reference/android/Manifest.permission#WRITE_EXTERNAL_STORAGE
93+
[12]: https://developer.android.com/reference/android/Manifest.permission#FOREGROUND_SERVICE_CAMERA
6994
[148013]: https://github.com/flutter/flutter/issues/148013

packages/camera/camera_android_camerax/example/android/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
22
package="io.flutter.plugins.cameraxexample">
3+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CAMERA" />
34
<application
45
android:label="camera_android_camerax_example"
56
android:name="${applicationName}"

packages/camera/camera_android_camerax/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: camera_android_camerax
22
description: Android implementation of the camera plugin using the CameraX library.
33
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_android_camerax
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
5-
version: 0.6.5+2
5+
version: 0.6.5+3
66

77
environment:
88
sdk: ^3.4.0

0 commit comments

Comments
 (0)