# Package com.codename1.health

package com.codename1.health

Cross-platform health data: reading and writing samples, aggregating them over time, watching the store for changes, and recording workouts.

Start at `Health`, which is never null on any port. Backed by HealthKit on iOS and watchOS, by Health Connect on Android, by a scriptable virtual store in the simulator, and by a local store on the desktop and JavaScript ports.

##### Two platform truths this API does not hide

Read authorization is unknowable on iOS. HealthKit reports a denied read as an empty result, deliberately, so that an app cannot infer what a user is choosing to hide. There is therefore no `hasReadPermission` anywhere in this package, and your UI must say "no data available" rather than "you denied access".

Android never wakes your app for new data. Health Connect has no push mechanism, so subscriptions there are polled when your app runs.

##### Related packages

- `com.codename1.health.workout` -- live and recorded workout sessions.
- `com.codename1.health.sensors` -- Bluetooth GATT health sensors, which work on every port with Bluetooth LE regardless of whether a health store exists.

- Related Packages
  Package
  Description
  com.codename1.health.nutrition
  Logged food and drink, as a sparse set of nutrient amounts.
  com.codename1.health.sensors
  Standard Bluetooth SIG health sensors -- heart-rate straps, power meters, speed and cadence sensors, foot pods, thermometers, scales, blood-pressure cuffs and glucose meters.
  com.codename1.health.workout
  Workout recording, live where the operating system supports it and framework-recorded everywhere else.
- Class
  Description
  AggregateMetric
  What to compute over an aggregation bucket.
  AggregateQuery
  Describes a bucketed summary read against `HealthStore`.
  AggregateResult
  One bucket of an `AggregateQuery` result: a span of time and the metrics computed over it.
  BloodPressureSample
  A blood-pressure reading: systolic and diastolic together, plus an optional pulse.
  CategorySample
  An enumerated observation with no natural unit -- menstrual flow, for example.
  Health
  Entry point for the Codename One health API -- reading and writing health data, watching it for changes, recording workouts, and streaming from Bluetooth health sensors.
  HealthAccess
  One data type paired with one direction of access.
  HealthAggregationStyle
  How a `HealthDataType` combines over a time bucket.
  HealthAnchor
  An opaque cursor marking how far through a data type's change history the app has read.
  HealthAuthorizationStatus
  The app's authorization for one data type and one direction.
  HealthAvailability
  Whether a platform health store is usable right now, and if not, why.
  HealthBackgroundListener
  Receives health-store changes even after the app's process has been killed and relaunched.
  HealthBackgroundListenerFactory
  Creates `HealthBackgroundListener` instances after the app's process has been killed and relaunched.
  HealthChangeBatch
  A set of changes since the last time a subscription was drained.
  HealthChangeListener
  Receives health-store changes while the app is running.
  HealthConfigurationException
  Thrown when the app is missing build configuration that the health APIs cannot work without -- an absent `ios.NSHealthShareUsageDescription` build hint, a missing Health Connect privacy-policy declaration.
  HealthDataKind
  What shape of data a `HealthDataType` produces, and therefore which `HealthSample` subclass a query for it returns.
  HealthDataType
  A kind of health data -- steps, heart rate, sleep, body mass.
  HealthDeleteRequest
  Describes what to delete from `HealthStore`, either by identifier or by type and time range.
  HealthError
  Typed failure reasons carried by `HealthException`.
  HealthException
  The failure delivered through an `AsyncResource` when a health operation does not succeed.
  HealthInterval
  The bucket width of an `AggregateQuery` -- "per hour", "per calendar day", "per calendar month".
  HealthQuantity
  An immutable value paired with the `HealthUnit` it is expressed in.
  HealthRequestStatus
  Whether presenting the authorization sheet would actually show the user anything.
  HealthSample
  The base of every health record: what it measures and when.
  HealthSource
  Where a sample came from -- which app wrote it and, when known, which device produced it.
  HealthStore
  Reads, writes and watches the platform health store -- HealthKit on iOS, Health Connect on Android, a local store elsewhere.
  HealthSubscription
  A live handle on a registered subscription.
  HealthTimeRange
  A half-open span of time, `[start, end)`, in epoch milliseconds UTC.
  HealthUnit
  A unit of measure for health data.
  HealthUnitDimension
  The physical dimension of a `HealthUnit`.
  HealthWriteResult
  The outcome of a write.
  QuantitySample
  A numeric measurement with a unit -- the most common kind of health sample.
  RecordingMethod
  How a sample came to exist.
  SamplePage
  One page of samples, plus the token needed to fetch the next.
  SampleQuery
  Describes a read against `HealthStore`.
  SeriesSample
  A run of measurements that share one record identity -- a beat-to-beat heart-rate trace, a cadence series.
  SessionSample
  A bounded activity that groups child data -- a workout, a night's sleep, a logged meal.
  SleepSample
  A sleep session, optionally broken into `SleepStageInterval` spans.
  SleepStage
  One stage within a `SleepSample`.
  SleepStageInterval
  A contiguous span of one `SleepStage` inside a `SleepSample`.
  SleepStageSupport
  How much stage detail a `SleepSample` actually carries.
  SubscriptionRequest
  Describes a standing subscription to changes in the health store.
  WorkoutActivityType
  What kind of exercise a workout records.
  WorkoutSample
  A completed workout: what kind, how long, and the totals the platform computed for it.