DataType

public final class DataType extends Object
implements Parcelable Parcelable

The data type defines the schema for a stream of data being collected by, inserted into, or queried from Google Fit. The data type defines only the representation and format of the data, and not how it's being collected, the sensor being used, or the parameters of the collection.

A data type contains one or more fields. In case of multi-dimensional data (such as location with latitude, longitude, and accuracy) each field represents one dimension. Each data type field has a unique name which identifies it. The field also defines the format of the data (such as int or float).

The data types in the com.google namespace are shared with any app with the user consent. These are fixed and can only be updated in new releases of the platform. This class contains constants representing each of the com.google data types, each prefixed with TYPE_. Custom data types can be accessed via the ConfigClient.

Certain data types can represent aggregates, and can be computed as part of read requests by calling DataReadRequest.Builder.aggregate(DataType) This class contains constants for all the valid aggregates, each prefixed with AGGREGATE_. The aggregates for each input type can be queried via getAggregatesForInput(DataType).

Constant Summary

String MIME_TYPE_PREFIX The common prefix for data type MIME types, for use in intents.

Inherited Constant Summary

Field Summary

public static final DataType AGGREGATE_ACTIVITY_SUMMARY In the com.google.activity.summary data type, each data point represents a summary of all activity segments of a particular activity type over a time interval.
public static final DataType AGGREGATE_BASAL_METABOLIC_RATE_SUMMARY In the com.google.calories.bmr.summary data type, each data point represents the average, maximum and minimum basal metabolic rate, in kcal per day, over the time interval of the data point.
public static final DataType AGGREGATE_BODY_FAT_PERCENTAGE_SUMMARY In the com.google.body.fat.percentage.summary data type, each data point represents the average, maximum and minimum percentage over the time interval of the data point.
public static final DataType AGGREGATE_CALORIES_EXPENDED Aggregate calories expended, in kcal, during a time interval.
public static final DataType AGGREGATE_DISTANCE_DELTA Aggregate distance, in meters, during a time interval.
public static final DataType AGGREGATE_HEART_POINTS In the com.google.heart_minutes.summary data type, each data point represents heart points aggregated over the query window.
public static final DataType AGGREGATE_HEART_RATE_SUMMARY In the com.google.heart_rate.summary data type, each data point represents average, maximum and minimum beats per minute over the time interval of the data point.
public static final DataType AGGREGATE_HEIGHT_SUMMARY In the com.google.height.summary data type, each data point represents the average, maximum and minimum height, in meters, over the time interval of the data point.
public static final DataType AGGREGATE_HYDRATION In the com.google.hydration data type, the field_volume in the data point represents the volume, in liters, of water consumed by a user as part of a single drink.
public static final DataType AGGREGATE_LOCATION_BOUNDING_BOX In the com.google.location.bounding_box data type, a data point represents the bounding box computed over user's location data points over a time interval.
public static final DataType AGGREGATE_MOVE_MINUTES Aggregate number of move minutes during a time interval.
public static final DataType AGGREGATE_NUTRITION_SUMMARY In the com.google.nutrition.summary data type, each data point represents the sum of all nutrition entries over the time interval of the data point.
public static final DataType AGGREGATE_POWER_SUMMARY In the com.google.power.summary data type, each data point represents average, maximum and minimum watts over the time interval of the data point.
public static final DataType AGGREGATE_SPEED_SUMMARY In the com.google.speed.summary data type, each data point represents the average, maximum and minimum speed over ground, in meters/second, over the time interval of the data point.
public static final DataType AGGREGATE_STEP_COUNT_DELTA Aggregate number of steps during a time interval.
public static final DataType AGGREGATE_WEIGHT_SUMMARY In the com.google.weight.summary data type, each data point represents the average, maximum and minimum weight, in kilograms, over the time interval of the data point.
public static final DataType TYPE_ACTIVITY_SEGMENT In the com.google.activity.segment data type, each data point represents a continuous time interval with a single activity value.
public static final DataType TYPE_BASAL_METABOLIC_RATE In the com.google.calories.bmr data type, each data point represents the basal metabolic rate of energy expenditure at rest of the user at the time of the reading, in kcal per day.
public static final DataType TYPE_BODY_FAT_PERCENTAGE In the com.google.body.fat.percentage data type, each data point represents a measurement of the total fat mass in a person's body as a percentage of the total body mass.
public static final DataType TYPE_CALORIES_EXPENDED In the com.google.calories.expended data type, each data point represents the number of calories expended, in kcal, over the time interval of the data point.
public static final DataType TYPE_CYCLING_PEDALING_CADENCE In the com.google.cycling.pedaling.cadence data type, each data point represents an instantaneous measurement of the pedaling rate in crank revolutions per minute.
public static final DataType TYPE_CYCLING_PEDALING_CUMULATIVE In the com.google.cycling.pedaling.cumulative data type, each data point represents the number of rotations taken from the start of the count.
public static final DataType TYPE_CYCLING_WHEEL_REVOLUTION In the com.google.cycling.wheel_revolution.cumulative data type, each data point represents the number of revolutions taken from the start of the count.
public static final DataType TYPE_CYCLING_WHEEL_RPM In the com.google.cycling.wheel_revolution.rpm data type, each data point represents an instantaneous measurement of the wheel in revolutions per minute.
public static final DataType TYPE_DISTANCE_DELTA In the com.google.distance.delta data type, each data point represents the distance covered, in meters, since the last reading.
public static final DataType TYPE_HEART_POINTS In the com.google.heart_minutes data type, each data point represents derived heart points.
public static final DataType TYPE_HEART_RATE_BPM In the com.google.heart_rate.bpm data type, each data point represents an instantaneous measurement of the heart rate in beats per minute.
public static final DataType TYPE_HEIGHT In the com.google.height data type, each data point represents the height of the user at the time of the reading, in meters.
public static final DataType TYPE_HYDRATION In the com.google.hydration data type, the field_volume in the data point represents the volume, in liters, of water consumed by a user as part of a single drink.
public static final DataType TYPE_LOCATION_SAMPLE In the com.google.location.sample data type, each data point represents the user's location at a given instant.
public static final DataType TYPE_LOCATION_TRACK This field is deprecated. Use TYPE_LOCATION_SAMPLE instead.
public static final DataType TYPE_MOVE_MINUTES In the com.google.active_minutes data type, each data point represents derived active minutes.
public static final DataType TYPE_NUTRITION In the com.google.nutrition data type, each data point represents the value of all nutrients consumed as part of a meal or a food item.
public static final DataType TYPE_POWER_SAMPLE In the com.google.power.sample data type, each data point represents an instantaneous measurement of power in watts.
public static final DataType TYPE_SLEEP_SEGMENT In the com.google.sleep.segment data type, each data point represents a continuous time interval with a single sleep segment type.
public static final DataType TYPE_SPEED In the com.google.speed data type, each data point represents the instantaneous speed over ground, in meters/second.
public static final DataType TYPE_STEP_COUNT_CADENCE In the com.google.step_count.cadence data type, each data point represents an instantaneous measurement of the cadence in steps per minute.
public static final DataType TYPE_STEP_COUNT_DELTA In the com.google.step_count.delta data type, each data point represents the number of steps taken since the last reading.
public static final DataType TYPE_WEIGHT In the com.google.weight data type, each data point represents the weight of the user at the time of the reading, in kilograms.
public static final DataType TYPE_WORKOUT_EXERCISE In the com.google.activity.exercise data type, each data point represents a single continuous set of a workout exercise performed by a user.

Public Method Summary

boolean
equals(Object other)
DataType
getAggregateType()
Returns the aggregate output type for this type, or null if the type does not support aggregation.
static List<DataType>
getAggregatesForInput(DataType inputDataType)
This method is deprecated. Use getAggregateType() instead.
List<Field>
getFields()
Returns the ordered list of fields for the data type.
static String
getMimeType(DataType dataType)
Returns the MIME type for a particular DataType.
String
getName()
Returns the namespaced name which uniquely identifies this data type.
int
int
indexOf(Field field)
Returns the index of a field.
String
void
writeToParcel(Parcel dest, int flags)

Inherited Method Summary

Constants

public static final String MIME_TYPE_PREFIX

The common prefix for data type MIME types, for use in intents. The MIME type for a particular data type will be this prefix followed by the data type name. Examples:

     vnd.google.fitness.data_type/com.google.heart_rate.bpm
     vnd.google.fitness.data_type/com.google.activity.segment
     vnd.google.fitness.data_type/com.example.my_type
 
The data type's name is returned by getName(). The full MIME type can be computed by getMimeType(DataType).
Constant Value: "vnd.google.fitness.data_type/"

Fields

public static final DataType AGGREGATE_ACTIVITY_SUMMARY

In the com.google.activity.summary data type, each data point represents a summary of all activity segments of a particular activity type over a time interval. The data type has three fields:

  1. activity an activity from FitnessActivities, as described in Field.FIELD_ACTIVITY.
  2. duration an integer denoting the total time spent, in milliseconds, in this activity across all segments over the time interval of this data point
  3. num_segments number of distinct activity segments over the time interval of this data point

Because this is an aggregate data type, it should only be read and not written to.

public static final DataType AGGREGATE_BASAL_METABOLIC_RATE_SUMMARY

In the com.google.calories.bmr.summary data type, each data point represents the average, maximum and minimum basal metabolic rate, in kcal per day, over the time interval of the data point.

Because this is an aggregate data type, it should only be read and not written to.

public static final DataType AGGREGATE_BODY_FAT_PERCENTAGE_SUMMARY

In the com.google.body.fat.percentage.summary data type, each data point represents the average, maximum and minimum percentage over the time interval of the data point.

Because this is an aggregate data type, it should only be read and not written to.

public static final DataType AGGREGATE_CALORIES_EXPENDED

Aggregate calories expended, in kcal, during a time interval. This data type is equivalent to the one used for non-aggregated data. The full definition can be found at TYPE_CALORIES_EXPENDED.

public static final DataType AGGREGATE_DISTANCE_DELTA

Aggregate distance, in meters, during a time interval. This data type is equivalent to the one used for non-aggregated data. The full definition can be found at TYPE_DISTANCE_DELTA.

public static final DataType AGGREGATE_HEART_POINTS

In the com.google.heart_minutes.summary data type, each data point represents heart points aggregated over the query window.

Because this is an aggregate data type, it should only be read and not written to.

The field intensity denotes the number of heart points earned over the time interval of the point, including bonus multipliers for minutes of strenuous activity.

The field duration contains the number of minutes in which heart points were earned, that is, ignoring multipliers.

public static final DataType AGGREGATE_HEART_RATE_SUMMARY

In the com.google.heart_rate.summary data type, each data point represents average, maximum and minimum beats per minute over the time interval of the data point.

Because this is an aggregate data type, it should only be read and not written to.

You can manually write heart rate data or you can subscribe to the TYPE_HEART_RATE_BPM data type to record heart rate data. This subscription requires the Manifest.permission.BODY_SENSORS permission.

public static final DataType AGGREGATE_HEIGHT_SUMMARY

In the com.google.height.summary data type, each data point represents the average, maximum and minimum height, in meters, over the time interval of the data point.

Because this is an aggregate data type, it should only be read and not written to.

public static final DataType AGGREGATE_HYDRATION

In the com.google.hydration data type, the field_volume in the data point represents the volume, in liters, of water consumed by a user as part of a single drink. The timestamp indicates when the drink was consumed.

public static final DataType AGGREGATE_LOCATION_BOUNDING_BOX

In the com.google.location.bounding_box data type, a data point represents the bounding box computed over user's location data points over a time interval. Each bounding box has four fields:

  1. low_latitude minimum latitude of the box, represented as a float, in degrees
  2. low_longitude minimum longitude of the box, represented as a float, in degrees
  3. high_latitude maximum latitude of the box, represented as a float, in degrees
  4. high_longitude maximum longitude of the box, represented as a float, in degrees
Because this is an aggregate data type, it should only be read and not written to.

Registering to, or subscribing to data of this type requires Manifest.permission.ACCESS_FINE_LOCATION

public static final DataType AGGREGATE_MOVE_MINUTES

Aggregate number of move minutes during a time interval. This data type is equivalent to the one used for non-aggregated data. The full definition can be found at TYPE_MOVE_MINUTES.

public static final DataType AGGREGATE_NUTRITION_SUMMARY

In the com.google.nutrition.summary data type, each data point represents the sum of all nutrition entries over the time interval of the data point.

In the nutrients field map, each value will represent the sum of the nutrient over all of the entries in the interval. If the nutrient was not present in any of the entries, it won't be present on the aggregate map either.

If all of the original entries are for the same meal, the meal_type field will also be set.

public static final DataType AGGREGATE_POWER_SUMMARY

In the com.google.power.summary data type, each data point represents average, maximum and minimum watts over the time interval of the data point.

Because this is an aggregate data type, it should only be read and not written to.

public static final DataType AGGREGATE_SPEED_SUMMARY

In the com.google.speed.summary data type, each data point represents the average, maximum and minimum speed over ground, in meters/second, over the time interval of the data point.

Because this is an aggregate data type, it should only be read and not written to.

public static final DataType AGGREGATE_STEP_COUNT_DELTA

Aggregate number of steps during a time interval. This data type is equivalent to the one used for non-aggregated data. The full definition can be found at TYPE_STEP_COUNT_DELTA.

public static final DataType AGGREGATE_WEIGHT_SUMMARY

In the com.google.weight.summary data type, each data point represents the average, maximum and minimum weight, in kilograms, over the time interval of the data point.

Because this is an aggregate data type, it should only be read and not written to.

public static final DataType TYPE_ACTIVITY_SEGMENT

In the com.google.activity.segment data type, each data point represents a continuous time interval with a single activity value. Activity values are described in Field.FIELD_ACTIVITY.

The start time of the data point must always be present as it represents the start of the activity, with the timestamp representing the activity's end time. Data point time intervals should be non-overlapping, although they do not need to be contiguous. In case when two activities happen at the same time, the most significant one should be used.

From API level 29, recording data of this type requires the ACTIVITY_RECOGNITION runtime permission.

public static final DataType TYPE_BASAL_METABOLIC_RATE

In the com.google.calories.bmr data type, each data point represents the basal metabolic rate of energy expenditure at rest of the user at the time of the reading, in kcal per day.

Because the recorded BMR is instantaneous, the start time should not be set.

public static final DataType TYPE_BODY_FAT_PERCENTAGE

In the com.google.body.fat.percentage data type, each data point represents a measurement of the total fat mass in a person's body as a percentage of the total body mass.

Since this is an instantaneous measurement, start time should not be set.

public static final DataType TYPE_CALORIES_EXPENDED

In the com.google.calories.expended data type, each data point represents the number of calories expended, in kcal, over the time interval of the data point. The field value is stored as a float. Note: this total calories number includes BMR calories expended.

Start and end times should be set to denote the duration over which the calories were expended.

From API level 29, recording data of this type requires the ACTIVITY_RECOGNITION runtime permission.

public static final DataType TYPE_CYCLING_PEDALING_CADENCE

In the com.google.cycling.pedaling.cadence data type, each data point represents an instantaneous measurement of the pedaling rate in crank revolutions per minute.

Start time should be left unset. Different data sources will need to monitor the rotations of the crank for different amounts of time before calculating the instantaneous RPM. This should be indicated as part of the data source and not the data point.

public static final DataType TYPE_CYCLING_PEDALING_CUMULATIVE

In the com.google.cycling.pedaling.cumulative data type, each data point represents the number of rotations taken from the start of the count. When using this data type, each revolution can be reported multiple times, as the values of each data point are monotonically increasing. To calculate the number of revolutions during an interval, the value at the end of the interval should be subtracted from the value at the beginning.

Note that the count may reset to zero at different times depending on the data source. When available, the data source should indicate the beginning of the count by setting the start time of the data point to the time of the start of the count. Alternatively, a data point with a value of zero can be used to indicate the resetting of the count. If neither of these is available, the count resetting can be inferred in a best-effort basis by detecting decreases in the total value.

public static final DataType TYPE_CYCLING_WHEEL_REVOLUTION

In the com.google.cycling.wheel_revolution.cumulative data type, each data point represents the number of revolutions taken from the start of the count. When using this data type, each revolution can be reported multiple times, as the values of each data point are monotonically increasing. To calculate the number of revolutions during an interval, the value at the end of the interval should be subtracted from the value at the beginning.

Note that the count may reset to zero at different times depending on the data source. When available, the data source should indicate the beginning of the count by setting the start time of the data point to the time of the start of the count. Alternatively, a data point with a value of zero can be used to indicate the resetting of the count. If neither of these is available, the count resetting can be inferred in a best-effort basis by detecting decreases in the total value.

public static final DataType TYPE_CYCLING_WHEEL_RPM

In the com.google.cycling.wheel_revolution.rpm data type, each data point represents an instantaneous measurement of the wheel in revolutions per minute.

Start time should be left unset. Different data sources will need to monitor the RPMs for different amounts of time before calculating the instantaneous RPM. This should be indicated as part of the data source and not the data point.

public static final DataType TYPE_DISTANCE_DELTA

In the com.google.distance.delta data type, each data point represents the distance covered, in meters, since the last reading. The total distance over an interval can be calculated by adding together all the values during the interval.

The start time of each data point should represent the start of the interval in which the distance was covered. The start time must be equal to or greater than the end time of the previous data point.

Registering to, or subscribing to data of this type requires Manifest.permission.ACCESS_FINE_LOCATION.

From API level 29, recording data of this type requires the ACTIVITY_RECOGNITION runtime permission.

public static final DataType TYPE_HEART_POINTS

In the com.google.heart_minutes data type, each data point represents derived heart points. We derive amount of heart points through time interval of the data point.

The field intensity denotes the intensity of the exercise. An intensity of 1 is used for moderate physical activity (for example walking faster than 2.5 mph, or cycling faster than 10 mph), with higher values awarded for more strenuous exercise.

The start time is always set.

Both start and end time of the data point are always aligned to natural minute markers.

public static final DataType TYPE_HEART_RATE_BPM

In the com.google.heart_rate.bpm data type, each data point represents an instantaneous measurement of the heart rate in beats per minute.

Start time should be left unset. Different data sources will need to monitor the heart's beat rate for different amounts of time before calculating the instantaneous heart rate. This should be indicated as part of the data source and not the data point.

Registering to, or subscribing to data of this type requires Manifest.permission.BODY_SENSORS

public static final DataType TYPE_HEIGHT

In the com.google.height data type, each data point represents the height of the user at the time of the reading, in meters.

Because the recorded height is instantaneous, the start time should not be set.

public static final DataType TYPE_HYDRATION

In the com.google.hydration data type, the field_volume in the data point represents the volume, in liters, of water consumed by a user as part of a single drink. The timestamp indicates when the drink was consumed.

Here's an example of creating a DataPoint to represent the user drinking 0.3 liters of water:

    DataSource hydrationSource = new DataSource.Builder()
            .setDataType(DataType.TYPE_HYDRATION)
            ...
            .build();

    DataPoint hydration =
         DataPoint.builder(hydrationSource)
             .setTimestamp(now.getMillis(), TimeUnit.MILLISECONDS)
             .setField(FIELD_VOLUME, 0.3f)
             .build();
 

public static final DataType TYPE_LOCATION_SAMPLE

In the com.google.location.sample data type, each data point represents the user's location at a given instant. The location data point has four fields:

  1. latitude is represented as a float, in degrees
  2. longitude is represented as a float, in degrees
  3. accuracy is represented as a float, in meters, and defines the radius of 68% confidence (so that it'd represent one standard deviation under a normal distribution) for latitude and longitude. See Location.getAccuracy() for more details.
  4. altitude is represented as a float, in meters above sea level. Accuracy is unknown (not represented by accuracy). Most mobile devices produce measurements that are up to 25 meters away from the correct altitude, so care must be taken to average several results for increased accuracy or use another source for elevation information. If altitude could not be determined for this location sample, this field is not set.

Registering to, or subscribing to data of this type requires Manifest.permission.ACCESS_FINE_LOCATION.

Clients can only read location data that they have written. Location data gathered via the recording client is not available via the history client.

public static final DataType TYPE_LOCATION_TRACK

This field is deprecated.
Use TYPE_LOCATION_SAMPLE instead.

The com.google.location.track data type represents a location point that is part of a track and which may have inexact timestamps.

Its fields are the same as location.sample. The difference between the two data types is that, while location.sample data points have an exact timestamp, location.track data points have an inexact time interval. The start time will represent the earliest time where the user may been at the location, and the end time will represent the latest time. Start time should always be set, even if it's the same as end time.

One use case of location.track is capturing the path of a user during an activity when the track for the path is known, but the exact time at each coordinate isn't.

Registering to, or subscribing to data of this type requires Manifest.permission.ACCESS_FINE_LOCATION

public static final DataType TYPE_MOVE_MINUTES

In the com.google.active_minutes data type, each data point represents derived active minutes. The singular value field is the duration of the point in minutes.

The start time is always set.

Both start and end time of the data point are always aligned to natural minute markers.

public static final DataType TYPE_NUTRITION

In the com.google.nutrition data type, each data point represents the value of all nutrients consumed as part of a meal or a food item.

The data point contains several fields. The nutrients field and either the meal type and/or the food item field are required.

  • nutrients contains all of the nutrient data for the entry
  • meal_type lists the type of meal, if known
  • food_item lists the particular food item for the entry, if known

In case the meal time is known, it should be reflected in the timestamps. Otherwise, start and end times should be set to the range in which the meal occurred.

The meal_type field accepts the following values, which are defined as constants in Field:

When the meal type isn't known, the field may be absent or set to "unknown". Apps should handle both cases accordingly.

The nutrients field is a map where the key holds the type of nutrient and the value holds the amount of the nutrient for the entry. Key values are represented by the NUTRIENT_XXX constants in Field. In case the amount of the nutrient for the entry is not known, no value for that nutrient should be added to the map. You may optionally use a value of zero when it is known that the nutrient is not present in the entry.

Here's an example of creating a DataPoint to represent the user eating a banana:

     DataSource nutritionSource = new DataSource.Builder()
         .setDataType(TYPE_NUTRITION)
         ...
         .build();

     Map<String, Float> nutrients = new HashMap<>();
     nutrients.put(NUTRIENT_TOTAL_FAT, 0.4f);
     nutrients.put(NUTRIENT_SODIUM, 1f);
     nutrients.put(NUTRIENT_POTASSIUM, 422f);

     DataPoint banana =
         DataPoint.builder(nutritionSource)
             .setTimestamp(now.getMillis(), TimeUnit.MILLISECONDS)
             .setField(FIELD_FOOD_ITEM, "banana")
             .setField(FIELD_MEAL_TYPE, MEAL_TYPE_SNACK)
             .setField(FIELD_NUTRIENTS, nutrients)
             .build();
 

public static final DataType TYPE_POWER_SAMPLE

In the com.google.power.sample data type, each data point represents an instantaneous measurement of power in watts. The field value is stored as a float.

Because the recorded power is instantaneous, the start time should not be set.

public static final DataType TYPE_SLEEP_SEGMENT

In the com.google.sleep.segment data type, each data point represents a continuous time interval with a single sleep segment type. Sleep segment types are described in Field.FIELD_SLEEP_SEGMENT_TYPE.

The start time of the data point must always be present as it represents the start of the stage, with the timestamp representing the end time of the sleep stage. Data point time intervals should be non-overlapping, although they do not need to be contiguous. In case when two sleep stages happen at the same time, the most significant one should be used.

public static final DataType TYPE_SPEED

In the com.google.speed data type, each data point represents the instantaneous speed over ground, in meters/second. The value represents the scalar magnitude of the speed, so negative values should not occur.

Because the recorded speed is instantaneous, the start time should not be set.

Registering to, or subscribing to data of this type requires Manifest.permission.ACCESS_FINE_LOCATION

public static final DataType TYPE_STEP_COUNT_CADENCE

In the com.google.step_count.cadence data type, each data point represents an instantaneous measurement of the cadence in steps per minute.

Both feet are used for calculating cadence, so if a sensor only measures one foot the value measurement is doubled.

Start time should be left unset.

public static final DataType TYPE_STEP_COUNT_DELTA

In the com.google.step_count.delta data type, each data point represents the number of steps taken since the last reading. When using this data type, each step is only ever reported once, in the reading immediately succeeding the step. By adding all of the values together for a period of time, the total number of steps during that period can be computed.

As an example, if a user walked a total of 5 steps, with 3 different readings, the values for each reading might be [1, 2, 2].

The start time of each data point should represent the start of the interval in which steps were taken. The start time must be equal to or greater than the end time of the previous data point.

From API level 29, recording data of this type requires the ACTIVITY_RECOGNITION runtime permission.

public static final DataType TYPE_WEIGHT

In the com.google.weight data type, each data point represents the weight of the user at the time of the reading, in kilograms.

Because the recorded weight is instantaneous, the start time should not be set.

public static final DataType TYPE_WORKOUT_EXERCISE

In the com.google.activity.exercise data type, each data point represents a single continuous set of a workout exercise performed by a user.

The data point contains fields for the exercise type, the number of repetitions of the exercise, the duration of the exercise, and the resistance.

The exercise type is specified as a string. Several canonical exercise types are specified in WorkoutExercises. If the exercise performed by the user isn't described by any of those values, a different value can be entered. Whenever possible, the new value should be prefixed by the canonical value it most closely resembles and separated by a dot. For instance, when entering an exercise value to represent a "push-up with clap", the canonical prefix for a push-up should be used, and the value could be represented as "pushup.clap".

The repetition field counts the number of repetitions of an exercise. It is intended for sets of exercises where a user performs a repetition several times. When the exercise is performed with an equal number of repetitions on each side (for instance, 10 curls on the right biceps and 10 curls on the left biceps), the repetition count of a single side only should be used (10 in this case). When the exercise is not a repeating exercise, or when the repetition count isn't known, the value should be left unset.

The duration field is specified in milliseconds, and holds the duration of an exercise for which the duration matters. Examples of such exercises include planks, stretches, as well as repeating exercises for which the user is attempting to perform as many repetitions as possible during a given time period. When the duration of the exercise isn't known, this field should be left unset.

The resistance_type and resistance fields specify the resistance of the exercise. The resistance type can hold any of the values in the Field.RESISTANCE_TYPE_XXX constants, which include constants for barbell, dumbell, and other common types of resistance. The resistance field will hold the actual weight in kilograms.

The timestamp of the data point should represent the time at which the user performed the exercise. If the exact time is not known, an approximate time may be entered. Note that, when reading data, exercise data points will be returned in timestamp order, so if the order of the exercises is known it should be reflected in the timestamps (even if they are approximate).

When several exercise data points are recorded together as part of a single workout, it's a good idea to also enter a Session for the duration of the workout, to help group the different exercises together.

Here's an example of creating a data point to represent a bench press set with 8 repetitions of 150kg:

      DataSource exerciseSource = new DataSource.Builder()
         .setDataType(TYPE_WORKOUT_EXERCISE)
         ...
         .build();

    DataPoint benchPress =
         DataPoint.builder(exerciseSource)
             .setTimestamp(now.getMillis(), TimeUnit.MILLISECONDS)
             .setField(FIELD_EXERCISE, WorkoutExercises.BENCH_PRESS)
             .setField(FIELD_REPETITIONS, 8)
             .setField(FIELD_RESISTANCE_TYPE, Field.RESISTANCE_TYPE_BARBELL)
             .setField(FIELD_RESISTANCE, 150.0f)
             .build();

 
And here's an example of creating a data point to represent 30 seconds of a plank:
      DataSource exerciseSource = new DataSource.Builder()
         .setDataType(TYPE_WORKOUT_EXERCISE)
         ...
         .build();

    DataPoint plank =
         DataPoint.builder(exerciseSource)
             .setTimestamp(now.getMillis(), TimeUnit.MILLISECONDS)
             .setField(FIELD_EXERCISE, WorkoutExercises.PLANK)
             .setField(FIELD_DURATION, 30_000)
             .build();

 

Public Methods

public boolean equals (Object other)

public DataType getAggregateType ()

Returns the aggregate output type for this type, or null if the type does not support aggregation.

To check if a data type is supported for aggregation, check that the returned type is non-null.

public static List<DataType> getAggregatesForInput (DataType inputDataType)

This method is deprecated.
Use getAggregateType() instead.

Returns a list of output aggregate data types for the specified inputDataType.

To check if a data type is supported for aggregation, check that the returned list is not empty DataType.getAggregatesForInput(dataType).isEmpty().

public List<Field> getFields ()

Returns the ordered list of fields for the data type.

public static String getMimeType (DataType dataType)

Returns the MIME type for a particular DataType. The MIME type is used in intents such as the data view intent.

public String getName ()

Returns the namespaced name which uniquely identifies this data type.

public int hashCode ()

public int indexOf (Field field)

Returns the index of a field.

Throws
IllegalArgumentException If field isn't defined for this data type.

public String toString ()

public void writeToParcel (Parcel dest, int flags)