VitalsResult with the Activity Result API.
1
Add the Maven repository and SDK dependency
Declare the Neurofit Maven repository in your project-level Sync your Gradle project after making these changes. The SDK is under 1 MB and introduces no additional analytics or tracking dependencies.
settings.gradle.kts so Gradle knows where to resolve the artifact. Then add the implementation dependency to your app module’s build.gradle.kts.settings.gradle.kts
build.gradle.kts (app module)
If your project still uses Groovy-based
.gradle files, replace url = uri(...) with url "https://sdk.neurofit.app/vitals-android" and use single-quote strings for the dependency coordinate.2
Add permissions to AndroidManifest.xml
The SDK requires camera hardware to capture the photoplethysmography signal. Add both the
CAMERA permission and the camera hardware feature declaration to your AndroidManifest.xml. Marking the feature as required="true" prevents the app from being installed on devices that lack a rear camera.AndroidManifest.xml
3
Initialize the SDK in Application.onCreate()
Call
VitalsSDK.configure once during application startup so the license is validated before any scan is launched. The Application subclass is the recommended location. Register it in your manifest with android:name=".MyApplication".MyApplication.kt
4
Launch VitalsScanActivity
The SDK ships
VitalsScanActivity, which owns the full scan UI including finger placement guidance, countdown, and quality feedback. The recommended approach is the Activity Result API introduced in AndroidX Activity 1.2.- Activity Result API (recommended)
- startActivityForResult (legacy)
Register the contract once at class level, then call
launch whenever you want to start a scan. The lambda receives a nullable VitalsResult — it is null only if the activity was cancelled before completion.MainActivity.kt
5
Handle scan results
After a successful scan, check
qualityTier before accessing any metric fields. A WITHHELD result means the signal was too noisy or unstable to produce a reliable reading — surface a retry prompt rather than displaying partial numbers.Result handling
breathingRate may be null even in ACCEPTED readings when the breathing signal did not reach the confidence threshold. Treat null as “not available this scan” rather than an error, and avoid displaying a placeholder value.6
Handle exceptions and edge cases
VitalsException is thrown (or delivered via the result callback) when the SDK encounters an unrecoverable condition. The three exception types and their recommended handling are described below.CAMERA_PERMISSION_DENIED
CAMERA_PERMISSION_DENIED
The user denied the runtime camera permission. Display a rationale dialog and direct the user to Settings → Apps → [Your App] → Permissions to grant access. Use
ActivityCompat.shouldShowRequestPermissionRationale to decide whether to show the rationale.LICENSE_INVALID
LICENSE_INVALID
The license key failed on-device validation. Confirm the key value in your Neurofit developer dashboard and verify it is being read correctly from your build configuration. This error cannot be recovered at runtime without a valid license key.
SCAN_INTERRUPTED
SCAN_INTERRUPTED
The scan was stopped before completion — for example, because the app was sent to the background or a system interruption (such as a phone call) occurred. You can offer an immediate retry without any additional reset step.
UNKNOWN
UNKNOWN
An unexpected condition occurred that does not map to any of the named exception types. Log the exception for diagnostics and surface a generic failure message to the user. If this exception occurs consistently, contact support@neurofit.app with your SDK version and reproduction steps.
The Neurofit Vitals SDK requires Android API 24 (Android 7.0 Nougat) or higher. Set
minSdk = 24 in your app module’s build.gradle.kts if it is not already at that level.