Health Connect integration begins with availability and permissions, but reliable synchronization needs a model for change.
Request only the record types required by current features and explain their use. Permission is granular; the application should work with partial access rather than reducing it to one boolean.
Normalize platform records behind a manager:
interface HealthDataSource {
suspend fun readChanges(token: String?): HealthChangePage
suspend fun aggregateDay(day: LocalDate, zone: ZoneId): DailyHealth
}
Persist change tokens only after local data commits. Replay after failure must be safe through stable record identifiers.
Source applications can overlap. Prefer Health Connect aggregation APIs where they match the metric, and define source priority when raw records require reconciliation.
Calendar days use the user's zone, including daylight-saving transitions. Store instants for events and explicit local dates for daily products.
Handle revoked permission as a normal state. Preserve already imported data according to product and privacy policy, stop future reads, and tell the user what is unavailable.
Test missing provider support, partial permissions, token expiry, deletion changes, repeated pages, and timezone movement. Health Connect is a source API; synchronization gives its data durable product meaning.