資料類型清單

透過集合功能整理內容 你可以依據偏好儲存及分類內容。

Health Connect 支援超過 50 種不同的資料類型,可讓使用者測量單車車速、體溫等各種資訊。

如需可用資料類型的完整清單,請參閱「Jetpack 參考資料」。

Health Connect 支援的資料類型是依據常見使用情形提供,並盡可能提供多樣化的資料。Health Connect 致力於提供全方位健康與健身資料的總覽與儲存。在參照 Jetpack 參考資料前,請記住 Health Connect 的資料類型可分為以下類別:

  • 活動:這會擷取使用者從事的活動。可以包括各種健康與健身活動,例如跑步、游泳、冥想和睡眠。
  • 身體測量:這會擷取與身體相關的常見資料。包括擷取使用者的體重 (或使用者的基礎代謝率) 以及其他資料類型。
  • 週期追蹤:這會擷取月經週期和相關資料點,例如排卵測試的二元結果。
  • 營養:擷取水份和營養資料類型,前者代表使用者一次飲用的水量,後者包含許多選用欄位,包括卡路里、糖和鎂,可記錄使用者攝入的營養素。
  • 睡眠:這會擷取與使用者睡眠時間間隔長度及睡眠類型相關的資料。
  • 生命體徵:這會擷取關於使用者一般健康的重要資訊。包括血糖、體溫以及血氧飽和度。

其他資料屬性

Health Connect API 中的資料也會包含下列屬性:

  • Health Connect ID:系統會為每一個資料點指派專屬的 ID/UUID 參考值。這適用於標準 CRUD 作業,例如刪除。
  • DataOrigin/Device:Health Connect 會儲存資料來源裝置的相關資訊。例如,您可以得知裝置的製造商和型號。
  • 用戶端 ID:為協助解決衝突問題並簡化同步處理程序,Health Connect 會提供用戶端 ID,方便用戶端應用程式使用自己的 ID 參照資料。

專屬 ID (UID)

Health Connect 會為新插入的資料物件指派專屬 ID。這將有助於識別資料物件,並與其他物件區分,在讀取、更新或刪除要求時更是如此。UID 與用戶端 ID 不同。用戶端 ID 是由用戶端應用程式指派,而 UID 則是由 Health Connect 指派。

注意事項

使用 Health Connect 中的 UID 時,請記得下列額外資訊:

  • 工作階段只有一組 UID,但工作階段內的資料各有專屬的 UID。
  • UID 不會與時間戳記綁定或相關聯。
  • 某些用途可能需要在工作流程中儲存特定的 UID。例如,擷取使用者剛登錄的資料,以便其顯示。

Health Connect 時間

所有寫入 Health Connect 的資料都必須指定時區偏移資訊。指定可用時區偏移,可讓讀取資料的應用程式以民間時間表示資料。「民用時間」是指與使用者相關的當地時間,不一定是世界標準時間 (UTC)。

在極少數的情況下,「時區偏移」可能無法使用。發生這個狀況時,即使沒有指定時區偏移資訊,也可以寫入 Health Connect。請盡量避免這種情況。

設定「時間」和「區域」

寫入 Health Connect 資料時,指定寫入時區資訊 (如前文所述),可提供時區資訊。不過,在某些情況下無法這樣運作,例如系統無法提供「時區偏移」。您的應用程式應準備處理這兩種資料,以符合您的特定情況。

權限

請求任何權限之前,應用程式必須先宣告權限。請參閱下表,瞭解從資料類型對應至權限的完整清單。

如果是 Alpha10 以上版本:

記錄類別類型 讀取權限宣告 寫入權限宣告
ActiveCaloriesBurned android.permission.health.READ_ACTIVE_CALORIES_BURNED android.permission.health.WRITE_ACTIVE_CALORIES_BURNED
BasalBodyTemperature android.permission.health.READ_BASAL_BODY_TEMPERATURE android.permission.health.WRITE_BASAL_BODY_TEMPERATURE
BasalMetabolicRate android.permission.health.READ_BASAL_METABOLIC_RATE android.permission.health.WRITE_BASAL_METABOLIC_RATE
BloodGlucose android.permission.health.READ_BLOOD_GLUCOSE android.permission.health.WRITE_BLOOD_GLUCOSE
BloodPressure android.permission.health.READ_BLOOD_PRESSURE android.permission.health.WRITE_BLOOD_PRESSURE
BodyFat android.permission.health.READ_BODY_FAT android.permission.health.WRITE_BODY_FAT
BodyTemperature android.permission.health.READ_BODY_TEMPERATURE android.permission.health.WRITE_BODY_TEMPERATURE
BoneMass android.permission.health.READ_BONE_MASS android.permission.health.WRITE_BONE_MASS
CervicalMucus android.permission.health.READ_CERVICAL_MUCUS android.permission.health.WRITE_CERVICAL_MUCUS
CyclingPedalingCadence android.permission.health.READ_EXERCISE android.permission.health.WRITE_EXERCISE
Distance android.permission.health.READ_DISTANCE android.permission.health.WRITE_DISTANCE
ElevationGained android.permission.health.READ_ELEVATION_GAINED android.permission.health.WRITE_ELEVATION_GAINED
ExerciseSession android.permission.health.READ_EXERCISE android.permission.health.WRITE_EXERCISE
FloorsClimbed android.permission.health.READ_FLOORS_CLIMBED android.permission.health.WRITE_FLOORS_CLIMBED
HeartRate android.permission.health.READ_HEART_RATE android.permission.health.WRITE_HEART_RATE
Height android.permission.health.READ_HEIGHT android.permission.health.WRITE_HEIGHT
Hydration android.permission.health.READ_HYDRATION android.permission.health.WRITE_HYDRATION
LeanBodyMass android.permission.health.READ_LEAN_BODY_MASS android.permission.health.WRITE_LEAN_BODY_MASS
MenstruationFlow android.permission.health.READ_MENSTRUATION android.permission.health.WRITE_MENSTRUATION
MenstruationPeriod android.permission.health.READ_MENSTRUATION android.permission.health.WRITE_MENSTRUATION
Nutrition android.permission.health.READ_NUTRITION android.permission.health.WRITE_NUTRITION
OvulationTest android.permission.health.READ_OVULATION_TEST android.permission.health.WRITE_OVULATION_TEST
OxygenSaturation android.permission.health.READ_OXYGEN_SATURATION android.permission.health.WRITE_OXYGEN_SATURATION
Power android.permission.health.READ_POWER android.permission.health.WRITE_POWER
RespiratoryRate android.permission.health.READ_RESPIRATORY_RATE android.permission.health.WRITE_RESPIRATORY_RATE
RestingHeartRate android.permission.health.READ_RESTING_HEART_RATE android.permission.health.WRITE_RESTING_HEART_RATE
SexualActivity android.permission.health.READ_SEXUAL_Activity android.permission.health.WRITE_SEXUAL_Activity
SleepSession android.permission.health.READ_SLEEP android.permission.health.WRITE_SLEEP
SleepStage android.permission.health.READ_SLEEP android.permission.health.WRITE_SLEEP
Speed android.permission.health.READ_SPEED android.permission.health.WRITE_SPEED
StepsCadence android.permission.health.READ_STEPS android.permission.health.WRITE_STEPS
Steps android.permission.health.READ_STEPS android.permission.health.WRITE_STEPS
TotalCaloriesBurned android.permission.health.READ_TOTAL_CALORIES_BURNED android.permission.health.WRITE_TOTAL_CALORIES_BURNED
Vo2Max android.permission.health.READ_VO2_MAX android.permission.health.WRITE_VO2_MAX
重量 android.permission.health.READ_WEIGHT android.permission.health.WRITE_WEIGHT
WheelchairPushes android.permission.health.READ_WHEELCHAIR_PUSHES android.permission.health.WRITE_WHEELCHAIR_PUSHES

如果是 Alpha09 以下版本:

記錄類別類型 讀取權限宣告 寫入權限宣告
ActiveCaloriesBurned androidx.health.permission.ActiveCaloriesBurned.READ androidx.health.permission.ActiveCaloriesBurned.WRITE
BasalBodyTemperature androidx.health.permission.BasalBodyTemperature.READ androidx.health.permission.BasalBodyTemperature.WRITE
BasalMetabolicRate androidx.health.permission.BasalMetabolicRate.READ androidx.health.permission.BasalMetabolicRate.WRITE
BloodGlucose androidx.health.permission.BloodGlucose.READ androidx.health.permission.BloodGlucose.WRITE
BloodPressure androidx.health.permission.BloodPressure.READ androidx.health.permission.BloodPressure.WRITE
BodyFat androidx.health.permission.BodyFat.READ androidx.health.permission.BodyFat.WRITE
BodyTemperature androidx.health.permission.BodyTemperature.READ androidx.health.permission.BodyTemperature.WRITE
BoneMass androidx.health.permission.BoneMass.READ androidx.health.permission.BoneMass.WRITE
CervicalMucus androidx.health.permission.CervicalMucus.READ androidx.health.permission.CervicalMucus.WRITE
CyclingPedalingCadence androidx.health.permission.CyclingPedalingCadence.READ androidx.health.permission.CyclingPedalingCadence.WRITE
Distance androidx.health.permission.Distance.READ androidx.health.permission.Distance.WRITE
ElevationGained androidx.health.permission.ElevationGained.READ androidx.health.permission.ElevationGained.WRITE
ExerciseSession androidx.health.permission.ExerciseSession.READ androidx.health.permission.ExerciseSession.WRITE
FloorsClimbed androidx.health.permission.FloorsClimbed.READ androidx.health.permission.FloorsClimbed.WRITE
HeartRate androidx.health.permission.HeartRate.READ androidx.health.permission.HeartRate.WRITE
Height androidx.health.permission.Height.READ androidx.health.permission.Height.WRITE
Hydration androidx.health.permission.Hydration.READ androidx.health.permission.Hydration.WRITE
LeanBodyMass androidx.health.permission.LeanBodyMass.READ androidx.health.permission.LeanBodyMass.WRITE
MenstruationFlow androidx.health.permission.MenstruationFlow.READ androidx.health.permission.MenstruationFlow.WRITE
Nutrition androidx.health.permission.Nutrition.READ androidx.health.permission.Nutrition.WRITE
OvulationTest androidx.health.permission.OvulationTest.READ androidx.health.permission.OvulationTest.WRITE
OxygenSaturation androidx.health.permission.OxygenSaturation.READ androidx.health.permission.OxygenSaturation.WRITE
Power androidx.health.permission.Power.READ androidx.health.permission.Power.WRITE
RespiratoryRate androidx.health.permission.RespiratoryRate.READ androidx.health.permission.RespiratoryRate.WRITE
RestingHeartRate androidx.health.permission.RestingHeartRate.READ androidx.health.permission.RestingHeartRate.WRITE
SexualActivity androidx.health.permission.SexualActivity.READ androidx.health.permission.SexualActivity.WRITE
SleepSession androidx.health.permission.SleepSession.READ androidx.health.permission.SleepSession.WRITE
SleepStage androidx.health.permission.SleepSession.READ androidx.health.permission.SleepSession.WRITE
Speed androidx.health.permission.Speed.READ androidx.health.permission.Speed.WRITE
StepsCadence androidx.health.permission.StepsCadence.READ androidx.health.permission.StepsCadence.WRITE
Steps androidx.health.permission.Steps.READ androidx.health.permission.Steps.WRITE
TotalCaloriesBurned androidx.health.permission.TotalCaloriesBurned.READ androidx.health.permission.TotalCaloriesBurned.WRITE
Vo2Max androidx.health.permission.Vo2Max.READ androidx.health.permission.Vo2Max.WRITE
重量 androidx.health.permission.Weight.READ androidx.health.permission.Weight.WRITE
WheelchairPushes androidx.health.permission.WheelchairPushes.READ androidx.health.permission.WheelchairPushes.WRITE