Skip to content

Instantly share code, notes, and snippets.

@magdamiu
Last active August 8, 2020 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save magdamiu/d97968ee5791b4725ea488a3a122819c to your computer and use it in GitHub Desktop.
Save magdamiu/d97968ee5791b4725ea488a3a122819c to your computer and use it in GitHub Desktop.
Smile, it’s CameraX! [preview and capture] | Preview - step 2: permission handling
// 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