You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.6 KiB
49 lines
1.6 KiB
6 years ago
|
---
|
||
|
layout: page
|
||
|
title: "Runtime Permissions"
|
||
6 years ago
|
description: "Permissions and Manifest setup"
|
||
5 years ago
|
order: 13
|
||
6 years ago
|
disqus: 1
|
||
6 years ago
|
---
|
||
|
|
||
5 years ago
|
CameraView needs two permissions:
|
||
6 years ago
|
|
||
|
- `android.permission.CAMERA` : required for capturing pictures and videos
|
||
|
- `android.permission.RECORD_AUDIO` : required for capturing videos with `Audio.ON` (the default)
|
||
|
|
||
|
### Declaration
|
||
|
|
||
|
The library manifest file declares the `android.permission.CAMERA` permission, but not the audio one.
|
||
|
This means that:
|
||
|
|
||
|
- If you wish to record videos with `Audio.ON` (the default), you should also add
|
||
|
`android.permission.RECORD_AUDIO` to required permissions
|
||
|
|
||
|
```xml
|
||
|
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
|
||
|
```
|
||
|
|
||
|
- If you want your app to be installed only on devices that have a camera, you should add:
|
||
|
|
||
|
```xml
|
||
|
<uses-feature
|
||
|
android:name="android.hardware.camera"
|
||
|
android:required="true"/>
|
||
|
```
|
||
|
|
||
|
If you don't request this feature, you can use `CameraUtils.hasCameras()` to detect if current
|
||
|
device has cameras, and then start the camera view.
|
||
|
|
||
|
### Handling
|
||
|
|
||
5 years ago
|
On Marshmallow+, the user must explicitly approve our permissions. You can either:
|
||
6 years ago
|
|
||
6 years ago
|
- handle permissions yourself and then call `open()` or `setLifecycleOwner()` once they are acquired
|
||
5 years ago
|
- let `CameraView` request permissions: we will present a permission request to the user based on
|
||
6 years ago
|
whether they are needed or not with the current configuration.
|
||
6 years ago
|
|
||
5 years ago
|
The automatic request is currently done at the activity level, so the permission request callback
|
||
|
`onRequestPermissionResults()` will be invoked on the parent activity, not the fragment.
|
||
|
|
||
|
The automatic request can be disabled by setting `app:cameraRequestPermissions="false"` in your
|
||
|
XML declaration.
|