Skip to main content
The Neurofit Vitals SDK brings a fully on-device 60-second rear-camera scan to your Android app, measuring heart rate, HRV, and respiration rate without sending any data to external servers. This guide covers everything from Gradle setup to handling your first VitalsResult with the Activity Result API.
1

Add the Maven repository and SDK dependency

Declare the Neurofit Maven repository in your project-level 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)
Sync your Gradle project after making these changes. The SDK is under 1 MB and introduces no additional analytics or tracking dependencies.
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
CAMERA is a dangerous permission — you must request it at runtime on API 23 and above. VitalsScanActivity requests the permission automatically before opening the camera, but your app should be prepared to handle the CAMERA_PERMISSION_DENIED exception if the user denies or permanently dismisses the dialog.
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
Keep your license key out of source control. Store it in local.properties or retrieve it from Android Keystore / EncryptedSharedPreferences at runtime. Reference it in build.gradle.kts via BuildConfig fields rather than hardcoding the string.
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.
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.
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.
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.
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.
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.
The rear camera is required and must be tested on a physical Android device. Emulators do not provide a real camera stream and will trigger a CAMERA_PERMISSION_DENIED or SCAN_INTERRUPTED exception when the SDK tries to access the sensor.