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.
Types
enum AggregateMetric | What to compute over an aggregation bucket. |
class AggregateQuery | Describes a bucketed summary read against HealthStore. |
class AggregateResult | One bucket of an AggregateQuery result: a span of time and the metrics computed over it. |
class BloodPressureSample | A blood-pressure reading: systolic and diastolic together, plus an optional pulse. |
class CategorySample | An enumerated observation with no natural unit – menstrual flow, for example. |
class 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. |
class HealthAccess | One data type paired with one direction of access. |
enum HealthAggregationStyle | How a HealthDataType combines over a time bucket. |
class HealthAnchor | An opaque cursor marking how far through a data type’s change history the app has read. |
enum HealthAuthorizationStatus | The app’s authorization for one data type and one direction. |
enum HealthAvailability | Whether a platform health store is usable right now, and if not, why. |
interface HealthBackgroundListener | Receives health-store changes even after the app’s process has been killed and relaunched. |
interface HealthBackgroundListenerFactory | Creates HealthBackgroundListener instances after the app’s process has been killed and relaunched. |
class HealthChangeBatch | A set of changes since the last time a subscription was drained. |
interface HealthChangeListener | Receives health-store changes while the app is running. |
class 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. |
enum HealthDataKind | What shape of data a HealthDataType produces, and therefore which HealthSample subclass a query for it returns. |
class HealthDataType | A kind of health data – steps, heart rate, sleep, body mass. |
class HealthDeleteRequest | Describes what to delete from HealthStore, either by identifier or by type and time range. |
enum HealthError | Typed failure reasons carried by HealthException. |
class HealthException | The failure delivered through an AsyncResource when a health operation does not succeed. |
class HealthInterval | The bucket width of an AggregateQuery – “per hour”, “per calendar day”, “per calendar month”. |
class HealthQuantity | An immutable value paired with the HealthUnit it is expressed in. |
enum HealthRequestStatus | Whether presenting the authorization sheet would actually show the user anything. |
class HealthSample | The base of every health record: what it measures and when. |
class HealthSource | Where a sample came from – which app wrote it and, when known, which device produced it. |
class HealthStore | Reads, writes and watches the platform health store – HealthKit on iOS, Health Connect on Android, a local store elsewhere. |
class HealthSubscription | A live handle on a registered subscription. |
class HealthTimeRange | A half-open span of time, [start, end), in epoch milliseconds UTC. |
class HealthUnit | A unit of measure for health data. |
enum HealthUnitDimension | The physical dimension of a HealthUnit. |
class HealthWriteResult | The outcome of a write. |
class QuantitySample | A numeric measurement with a unit – the most common kind of health sample. |
enum RecordingMethod | How a sample came to exist. |
class SamplePage | One page of samples, plus the token needed to fetch the next. |
class SampleQuery | Describes a read against HealthStore. |
class SeriesSample | A run of measurements that share one record identity – a beat-to-beat heart-rate trace, a cadence series. |
class SessionSample | A bounded activity that groups child data – a workout, a night’s sleep, a logged meal. |
class SleepSample | A sleep session, optionally broken into SleepStageInterval spans. |
enum SleepStage | One stage within a SleepSample. |
class SleepStageInterval | A contiguous span of one SleepStage inside a SleepSample. |
enum SleepStageSupport | How much stage detail a SleepSample actually carries. |
class SubscriptionRequest | Describes a standing subscription to changes in the health store. |
enum WorkoutActivityType | What kind of exercise a workout records. |
class WorkoutSample | A completed workout: what kind, how long, and the totals the platform computed for it. |