Last active
August 8, 2020 18:57
-
-
Save magdamiu/d97968ee5791b4725ea488a3a122819c to your computer and use it in GitHub Desktop.
Smile, it’s CameraX! [preview and capture] | Preview - step 2: permission handling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// manifest | |
<uses-feature android:name="android.hardware.camera.any" /> | |
<uses-permission android:name="android.permission.CAMERA" /> | |
// fragment or activity | |
if (areAllPermissionsGranted()) { | |
startCamera() | |
} else { | |
ActivityCompat.requestPermissions( | |
this, PERMISSIONS, CAMERA_REQUEST_PERMISSION_CODE) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment