Your app can record blood glucose data by writing to the
com.google.blood_glucose
data type. In this data type, each data point represents a single instantaneous
blood glucose reading. The data point contains fields for the blood glucose
concentration, temporal relationships to meals and sleep, and the source of the
specimen which was measured. All fields except for blood glucose concentration
are optional.
- The blood glucose concentration is measured in mmol/L (1 mmol/L is equivalent to 18 mg/dL).
- If specified, temporal relation to meal must have one of the values listed
in
FIELD_TEMPORAL_RELATION_TO_MEAL
. - Meal type must have one of the values listed in
FIELD_MEAL_TYPE
. If the meal type is not known, useMEAL_TYPE_UNKNOWN
. - If specified, temporal relation to sleep must have one of the values listed
in
FIELD_TEMPORAL_RELATION_TO_SLEEP
. - If specified, blood glucose specimen source must have one of the values
listed in
FIELD_BLOOD_GLUCOSE_SPECIMEN_SOURCE
.
To write a blood glucose data point, create a new DataSource
of TYPE_BLOOD_GLUCOSE
,
as shown in the following example.
DataSource bloodGlucoseSource = new DataSource.Builder()
.setDataType(TYPE_BLOOD_GLUCOSE)
...
.build();
DataPoint bloodGlucose = DataPoint.create(bloodGlucoseSource);
bloodGlucose.setTimestamp(now.getMillis(), MILLISECONDS);
bloodGlucose.getValue(FIELD_BLOOD_GLUCOSE_LEVEL).setFloat(5.0f); // 90 mg/dL
bloodGlucose.getValue(FIELD_TEMPORAL_RELATION_TO_MEAL)
.setInt(FIELD_TEMPORAL_RELATION_TO_MEAL_BEFORE_BREAKFAST);
bloodGlucose.getValue(FIELD_TEMPORAL_RELATION_TO_SLEEP)
.setInt(TEMPORAL_RELATION_TO_SLEEP_ON_WAKING);
bloodGlucose.getValue(FIELD_BLOOD_GLUCOSE_SPECIMEN_SOURCE)
.setInt(BLOOD_GLUCOSE_SPECIMEN_SOURCE_CAPILLARY_BLOOD);