Write Blood Glucose Data

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.

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);

发送以下问题的反馈:

此网页
Google Fit
Google Fit