Camera & Permissions
The Android SDK uses the front camera through CameraX. Your app must request camera permission before calling measureVitals().
Manifest
Section titled “Manifest”Add camera and internet permissions to the host app manifest:
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-permission android:name="android.permission.CAMERA" /><uses-permission android:name="android.permission.INTERNET" />Set android:required="false" if the app can install on devices without a camera and disable measurement at runtime.
Permission flow
Section titled “Permission flow”-
Check whether
Manifest.permission.CAMERAis already granted. -
Request permission with the AndroidX Activity Result API if it is missing.
-
Start measurement only after permission is granted.
-
Handle denial with a clear message or a link to app settings.
private val permissionLauncher = registerForActivityResult( ActivityResultContracts.RequestPermission(),) { granted -> if (granted) { startMeasurement() } else { showMessage("Camera permission is required to measure vitals.") }}
private fun startWhenAllowed() { val granted = ContextCompat.checkSelfPermission( this, Manifest.permission.CAMERA, ) == PackageManager.PERMISSION_GRANTED
if (granted) { startMeasurement() } else { permissionLauncher.launch(Manifest.permission.CAMERA) }}PreviewView
Section titled “PreviewView”The SDK is headless. Pass a caller-owned PreviewView if you want a live camera preview.
val previewView = PreviewView(this).apply { scaleType = PreviewView.ScaleType.FILL_CENTER}
lifecycleScope.launch { val result = sdk.measureVitals( MeasurementOptions( lifecycleOwner = this@MainActivity, previewView = previewView, ), )}If you pass previewView = null, the SDK still captures frames, but your app will not show a camera preview.
Capability checks
Section titled “Capability checks”Use getDeviceCapabilities() before showing scan UI on unsupported devices.
val capabilities = sdk.getDeviceCapabilities()
when { !capabilities.hasCamera -> showMessage("No camera found on this device.") !capabilities.hasFrontCamera -> showMessage("A front camera is required.") !capabilities.cameraPermissionGranted -> requestCameraPermission() else -> startMeasurement()}Best practices
Section titled “Best practices”- Request permission before the user taps the final scan action.
- Keep the scan screen lifecycle active while measuring.
- Pass an Activity or Fragment
LifecycleOwnerso CameraX can bind and release cleanly. - Show quality guidance from
onQualityStateoronQualityWarning. - Call
sdk.cancel()or cancel the coroutine when the user leaves the scan screen. - Call
sdk.destroy()when the SDK instance is no longer needed.
Next Steps
Section titled “Next Steps”- Methods - Start and cancel measurements
- Configuration - Register quality callbacks
- Error Handling - Handle permission errors