Skip to main content
Despia connects your web app to Health Connect, Android’s on-device store for health and fitness data. You use the same calls as Apple Health: readhealthkit://, writehealthkit://, healthkit://workouts, healthkit://observe and healthkit://unobserve, with the same identifiers and the same result shapes. One code path serves iPhone and Android. On top of that, healthconnect:// gives you what Health Connect offers beyond HealthKit: an availability check, the install flow, the Health Connect settings screen, explicit permission requests, time ranges and hourly buckets, deletes of your own records, and change tokens.
Android support is new. The type mapping, the request handling and the result shapes are covered by automated tests. Testing on devices is in progress, so check your flows on a real phone before you release.

Installation

Install despia-native as described on the Apple Health page. Nothing else is needed in your web app.

Setup

Health Connect is built into your Android app only when you turn it on, because Google Play reviews every app that asks for health permissions.
1

Choose the data types

List the types your app reads and writes. Use the HealthKit identifiers you already use on iOS (for example HKQuantityTypeIdentifierStepCount), Health Connect record names (for example StepsRecord), or Health Connect permission names (for example android.permission.health.READ_STEPS). Only these types are declared in your app, and Health Connect only asks the user for declared types.
2

Publish a privacy policy

Health Connect shows your privacy policy from its permission screen, and Google Play requires one for health permissions. Without a privacy policy URL, Health Connect is left out of the build.
3

Turn it on for your app

Contact support@despia.com with your app, the read and write lists, the privacy policy URL, and whether you need background reads (observers while the app is closed) or history older than 30 days. These become the build settings below.
4

Rebuild and complete the Play Console declaration

Rebuild the Android app. In Google Play Console, complete the Health apps declaration for the same data types. Health Connect access is part of the binary, so it cannot be changed over-the-air.
An identifier that Health Connect has no type for stops the build with its name, so a typo never ships silently.

Detecting the platform

Check for Android the same way you check for iOS, and send the same calls.

Availability and install

Health Connect runs on Android 9 and later. On Android 14 and later it is part of the system. On Android 13 and lower it is an app from Google Play, which the user may need to install or update.
string
available, update_required (the Health Connect app must be updated), unavailable (not installed, or Android 8), requires_android_8 (Android 7), or not_included (the app was built without Health Connect)
boolean
true when calls can read and write
boolean
true on Android 14 and later, where Health Connect is part of the system
string[]
The Health Connect permissions your build declares
string[]
The permissions the user has granted (only when available)
boolean
Whether background reads are granted
boolean
Whether reads older than 30 days are granted
On Android 7 (API 24 and 25), which the Health Connect library does not support, every health call answers at once with the same shapes as a build without Health Connect, using the code health_connect_requires_android_8 (status requires_android_8). Android 8 answers unavailable. healthConnectInstall is { opened, status }. When Health Connect is not usable, reads answer { "error": "health_connect_unavailable" } or { "error": "health_connect_update_required" } in healthkitResponse.

Permissions

As on iOS, the first read, write or observe of a type shows the Health Connect permission screen for the types in that call. Each type is asked at most once this way; after the user answers, later calls do not show the screen again. A type the user did not allow reads as an empty array, as on iOS. To ask again, for example from a settings page in your app, call healthconnect://permissions. It asks for every listed type that is not granted.
string
Types to read. Without read and write, every type your build declares is asked.
string
Types to write
boolean
Also ask for background reads
boolean
Also ask for data older than 30 days
notDeclared lists permissions your build does not declare. Health Connect cannot ask for them; add them to the build settings and rebuild. The user can open your privacy policy from the Health Connect permission screen, and on Android 14 and later from the system’s permission usage screen.

Read

Reads work exactly as on Apple Health: readhealthkit:// with identifiers on the host and days, raw=true and write in the query, or healthkit://read?types=.... The result lands in healthkitResponse, keyed by the identifier you passed.
Units and scales match iOS for the same identifier: kg for body mass, cm for height, a fraction from 0 to 1 for body fat and oxygen saturation, mg or mcg for nutrients, count/min for heart rate. Daily totals of cumulative types come from Health Connect’s own aggregation, which removes the overlap when several apps record the same activity. Sleep sessions return an inBed entry (value 0) for the whole session, followed by one entry per stage: awake 2, core 3 (Health Connect light sleep), deep 4, rem 5, and asleep 1 for sleep without a stage.

Time ranges and hourly buckets

healthconnect://read takes the same types, days, raw and write parameters, plus:
string
ISO 8601 start, for example 2026-11-20T00:00:00Z or 2026-11-20T00:00:00+04:00. Replaces days.
string
ISO 8601 end. Defaults to now.
string
day (default) or hour
Types can be HealthKit identifiers or Health Connect record names. When a read includes identifiers that Health Connect has no type for, they return an empty array and window.healthConnectLimits names each one with the reason. The same happens for skin temperature and mindfulness sessions when the Health Connect version on the device does not offer them yet (updating Health Connect adds them), and for a type whose read fails, with the error message as the reason.

Workouts

healthkit://workouts?days=30 returns Health Connect exercise sessions in the iOS workout shape, newest first, in healthkitWorkouts and in healthkitResponse.HKWorkoutTypeIdentifier. Workouts need only the exercise permission; when the user has not granted calories or distance, that field is 0, as on iOS.
activityType uses the iOS names (running, cycling, hiit, traditionalStrengthTraining, …). Health Connect types without an iOS twin use their own name in camelCase. exerciseType is the Health Connect type and title the session title when the recording app set one. Calories and distance are the ones recorded by the same app during the session. included= adds statistics per workout exactly as on iOS, for example included=HKQuantityTypeIdentifierHeartRateMax.

Write

writehealthkit://Identifier//Value saves a value in the same unit as on iOS and answers in healthkitWriteResponse ({ success, identifier, value, error }), calling window.onHealthKitWrite when you define it.
healthconnect://write writes by Health Connect record name, with the value in the same unit a read of that type returns (for example kg for WeightRecord, a 0 to 1 fraction for BodyFatRecord), and an optional time range:
Single-moment types are written at end (default now). Types that cover a period are written from start to end (default the last second). Blood pressure is one reading with both values. Category types (sleep, cycle tracking) are not written through these calls, as on iOS. Delete your own app’s records of one type in a range with healthconnect://delete?type=WeightRecord&days=7 (or start and end). Result in healthConnectDelete. Health Connect never lets an app delete another app’s data this way.

Observer

healthkit://observe and healthkit://unobserve take the same parameters as on iOS, keep observers across restarts, and keep observingHealthKit up to date.
Health Connect does not notify apps when data changes. Despia checks for changes with Health Connect change tokens when your app comes to the foreground and on a schedule set by frequency: hourly, daily, weekly, and every 15 minutes for immediate (the shortest interval Android allows). Checks while the app is closed need background reads (HEALTH_CONNECT_BACKGROUND and the user’s grant); without them, checks run when the app is opened. A new observer reports once when it starts. The webhook body matches iOS, with a source field:
userId is the Android device ID. Use a query parameter on server to identify your own users. A change counts as sent only when your server answers with a 2xx status. If the request fails, the same changes are sent again on the next check.

Change tokens

To sync changes yourself, take a token and read changes since it later:
Tokens expire after 30 days. When tokenExpired is true, read the data again and take a new token.

Type reference

Every HealthKit identifier below works on Android through Health Connect. Quantity identifiers take the HKQuantityTypeIdentifier prefix, categories HKCategoryTypeIdentifier. Health Connect types beyond HealthKit, by record name: ElevationGainedRecord, TotalCaloriesBurnedRecord, BasalMetabolicRateRecord (kcal/day), HeartRateVariabilityRmssdRecord, BodyWaterMassRecord, BoneMassRecord, SkinTemperatureRecord, SpeedRecord, PowerRecord, StepsCadenceRecord, MenstruationPeriodRecord, and NutritionRecord.<field> for one nutrient, including transFat, unsaturatedFat, folicAcid and energyFromFat. Blood pressure reads use BloodPressureRecord.systolic and BloodPressureRecord.diastolic.

HealthKit types without a Health Connect equivalent

These return an empty array on Android (characteristics return [{ value: "" }]), and healthConnectLimits names them:
  • Heart rate variability SDNN: Health Connect stores RMSSD (HeartRateVariabilityRmssdRecord).
  • Characteristics: date of birth, biological sex, blood type, skin type, wheelchair use, move mode.
  • Apple scores and metrics: stand time and stand hours, move time, walking steadiness, walking heart rate average, sleeping wrist temperature, sleeping breathing disturbances, AFib burden, workout effort, Nike Fuel.
  • Mobility and environment: walking step length, double support, asymmetry, stair speed, six-minute walk, running stride and form, audio exposure, UV exposure, time in daylight, underwater depth, water temperature.
  • Lung function, inhaler use, insulin delivery, alcohol, falls, electrodermal activity, perfusion index, body mass index.
  • Cross-country skiing distance and speed: Health Connect has one skiing type.
  • Symptom categories and the health event categories (heart rate notifications, pregnancy and cycle events, handwashing, toothbrushing).
These cannot be written on Android: the activity-specific distance, speed and power types (Health Connect records one value per time range and takes the activity from the exercise session), AppleExerciseTime, BasalEnergyBurned (write BasalMetabolicRateRecord instead), SkinTemperatureRecord, and the single blood pressure values (write BloodPressureRecord with both).

Builds without Health Connect

When an Android build does not include Health Connect, every health call still answers right away, so your code never waits: reads give { "error": "health_connect_not_included" }, writes give success: false, workouts [], observers [], and the despia-feature-not-included event fires.

Resources