public final class

DataPoint

extends Object
implements SafeParcelable
java.lang.Object
   ↳ com.google.android.gms.fitness.data.DataPoint

Class Overview

Represents a single data point in a data type's stream from a particular data source. A data point holds a value for each field, a timestamp and an optional start time. The exact semantics of each of these attributes is specified in the documentation for the particular data type, which can be found in DataTypes.

A data point can represent an instantaneous measurement, reading or inputted observation, as well as averages or aggregates over a time interval. Check the data type documentation to determine which is the case for a particular data type.

DataPoints always contain one value for each the data type field. Initially, all of the values are unset. After creating the data point, the appropriate values and timestamps should be set.

Summary

[Expand]
Inherited Constants
From interface android.os.Parcelable
From interface com.google.android.gms.common.internal.safeparcel.SafeParcelable
Fields
public static final Creator<DataPoint> CREATOR
Public Methods
static DataPoint create(DataSource dataSource)
Creates a new data point for the given dataSource.
int describeContents()
boolean equals(Object o)
static DataPoint extract(Intent intent)
Extracts a data point from a callback intent received after registering to a data source with a PendingIntent.
DataSource getDataSource()
Returns the data source for the data point.
DataType getDataType()
Returns the data type defining the format of the values in this data point.
long getEndTimeNanos()
Returns the end time of the interval represented by this data point, in nanoseconds since epoch.
DataSource getOriginalDataSource()
Returns the original data source for this data point.
long getStartTimeNanos()
Returns the start time of the interval represented by this data point, in nanoseconds since epoch.
long getTimestampNanos()
Returns the timestamp of the data point, in nanoseconds since epoch.
Value getValue(Field field)
Returns the value holder for the field with the given name.
int hashCode()
DataPoint setFloatValues(float... values)
Sets the values of this data point, where the format for all of its values is float.
DataPoint setIntValues(int... values)
Sets the values of this data point, where the format for all of its values is int.
DataPoint setTimeInterval(long startTime, long endTime, TimeUnit unit)
Sets the time interval of the data point in a given unit.
DataPoint setTimeIntervalNanos(long startTimeNanos, long endTimeNanos)
Sets the time interval for the data point, in case it represents an aggregation or average over a period of time.
DataPoint setTimestamp(long timestamp, TimeUnit unit)
Sets the timestamp of the data point in a given unit.
DataPoint setTimestampNanos(long timestampNanos)
Sets the timestamp of the data point, in case the data point represents an instantaneous reading, measurement, or input.
String toString()
void writeToParcel(Parcel parcel, int flags)
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.os.Parcelable

Fields

public static final Creator<DataPoint> CREATOR

Public Methods

public static DataPoint create (DataSource dataSource)

Creates a new data point for the given dataSource. An unset Value is created for each field of the data source's data type.

Returns
  • an empty data point instance

public int describeContents ()

public boolean equals (Object o)

public static DataPoint extract (Intent intent)

Extracts a data point from a callback intent received after registering to a data source with a PendingIntent.

Returns
  • the extracted DataPoint, or null if the given intent does not contain a DataPoint

public DataSource getDataSource ()

Returns the data source for the data point. If the data point is part of a DataSet, this will correspond to the data set's data source.

public DataType getDataType ()

Returns the data type defining the format of the values in this data point.

public long getEndTimeNanos ()

Returns the end time of the interval represented by this data point, in nanoseconds since epoch. This method is equivalent to getTimestampNanos()

public DataSource getOriginalDataSource ()

Returns the original data source for this data point. The original data source helps identify the source of the data point as it gets merged and transformed into different streams.

Note that, if this data point is part of a DataSet, the data source returned here may be different from the data set's data source. In case of transformed or merged data sets, each data point's original data source will retain the original attribution as much as possible, while the data set's data source will represent the merged or transformed stream.

public long getStartTimeNanos ()

Returns the start time of the interval represented by this data point, in nanoseconds since epoch.

public long getTimestampNanos ()

Returns the timestamp of the data point, in nanoseconds since epoch. For data points that represent intervals, this method will return the end time.

public Value getValue (Field field)

Returns the value holder for the field with the given name. This method can be used both to query the value and to set it.

Parameters
field one of the fields of this data type
Returns
  • the Value associated with the given field
Throws
IllegalArgumentException if the given field doesn't match any of the fields for this DataPoint's data type.

public int hashCode ()

public DataPoint setFloatValues (float... values)

Sets the values of this data point, where the format for all of its values is float.

Parameters
values the value for each field of the data point, in order

public DataPoint setIntValues (int... values)

Sets the values of this data point, where the format for all of its values is int.

Parameters
values the value for each field of the data point, in order

public DataPoint setTimeInterval (long startTime, long endTime, TimeUnit unit)

Sets the time interval of the data point in a given unit. See setTimeIntervalNanos(long, long) for more details.

Parameters
startTime the start time in the given unit, representing elapsed time since epoch
endTime the end time in the given unit, representing elapsed time since epoch
unit the unit of both start and end timestamps

public DataPoint setTimeIntervalNanos (long startTimeNanos, long endTimeNanos)

Sets the time interval for the data point, in case it represents an aggregation or average over a period of time. For data points that represent instantaneous samples, setTimestampNanos(long) should be used.

Examples of data types that represent intervals include:

Parameters
startTimeNanos the start time of the interval, in nanoseconds since epoch
endTimeNanos the end time of the interval, in nanoseconds since epoch

public DataPoint setTimestamp (long timestamp, TimeUnit unit)

Sets the timestamp of the data point in a given unit. See (long) for more details.

Parameters
timestamp the timestamp in the given unit, representing elapsed time since epoch
unit the unit of the given timestamp

public DataPoint setTimestampNanos (long timestampNanos)

Sets the timestamp of the data point, in case the data point represents an instantaneous reading, measurement, or input. For data points that represent intervals, setTimeIntervalNanos(long, long) should be used.

Examples of data types with instantaneous timestamp include:

Parameters
timestampNanos the time of the reading, in nanoseconds since epoch.

public String toString ()

public void writeToParcel (Parcel parcel, int flags)