public class

DataReadRequest

extends Object
implements Parcelable
java.lang.Object
   ↳ com.google.android.gms.fitness.request.DataReadRequest

Class Overview

Request for reading data from Google Fit. Use this request to specify the data types to read, as well as aggregation parameters. Read requests require a time range and allow reading data in detailed or aggregated fashion. A single request can be used to read multiple data types and data sources together.

Detailed Data

For requesting detailed data, the request should specify:
  • the time interval for the data
  • at least one data source or data type
Example usage for reading location samples during an interval:
     new DataReadRequest.Builder()
         .setTimeRange(startTime.getMillis(), endTime.getMillis(). TimeUnit.MILLISECONDS)
         .read(DataTypes.LOCATION_SAMPLE)
         .build();
 

Aggregated Data

For requesting aggregate data, the request should specify a valid bucketing strategy. Apps can request to bucket by time, activity type, activity segment, or session. Apps should also specify at least one input data source or data type to aggregate. See AGGREGATE_INPUT_TYPES for a list of valid input data types supported for aggregation.

The aggregation request should specify:

  • time interval for the data
  • at least one input data source or data type to aggregate and its corresponding output aggregate data type
  • bucketing strategy for aggregation

Example usage for selecting location bounding boxes for each hour:

     new DataReadRequest.Builder()
          .setTimeRange(startTime.getMillis(), endTime.getMillis(), TimeUnit.MILLISECONDS)
          .bucketByTime(1, TimeUnit.HOURS)
          .aggregate(DataTypes.LOCATION_SAMPLE, AggregateDataTypes.LOCATION_BOUNDING_BOX)
          .build();
 

Summary

Nested Classes
class DataReadRequest.Builder Builder used to create new DataReadRequests. 
Constants
int NO_LIMIT Constant specifying no limit has been set.
[Expand]
Inherited Constants
From interface android.os.Parcelable
Fields
public static final Creator<DataReadRequest> CREATOR
Public Methods
boolean equals(Object that)
DataSource getActivityDataSource()
Returns the data source used to get activity segments for creating buckets for data aggregation in this request.
List<DataSource> getAggregatedDataSources()
Returns all of the data sources that will be read then aggregated as part of this request.
List<DataType> getAggregatedDataTypes()
Returns all of the data types that will be read then aggregated as part of this request.
long getBucketDuration(TimeUnit timeUnit)
Returns the bucket duration for this request in the given time unit.
int getBucketType()
Returns the bucket type for data aggregation for this request.
List<DataSource> getDataSources()
Returns the data sources that should be read in this request.
List<DataType> getDataTypes()
Returns the data types for which default data sources should be read in this request.
long getEndTime(TimeUnit timeUnit)
Returns the end time for our query, in the specified time unit
List<Integer> getFilteredDataQualityStandards()
Returns the list of data quality standards which will restrict the data sources used in this query.
int getLimit()
Returns the max number of data points to return in the result.
long getStartTime(TimeUnit timeUnit)
Returns the start time for our query, in the specified time unit
int hashCode()
String toString()
void writeToParcel(Parcel dest, int flags)
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.os.Parcelable

Constants

public static final int NO_LIMIT

Constant specifying no limit has been set.

Constant Value: 0 (0x00000000)

Fields

public static final Creator<DataReadRequest> CREATOR

Public Methods

public boolean equals (Object that)

Parameters
that Object
Returns
boolean

public DataSource getActivityDataSource ()

Returns the data source used to get activity segments for creating buckets for data aggregation in this request.

This data source is used when bucketing by activity segment or activity type.

Returns
DataSource the data source, or null if unset

public List<DataSource> getAggregatedDataSources ()

Returns all of the data sources that will be read then aggregated as part of this request. Each data source will be read then aggregated as specified in aggregate(DataSource, DataType).

Returns
List<DataSource> the input data sources for aggregation, empty if none

public List<DataType> getAggregatedDataTypes ()

Returns all of the data types that will be read then aggregated as part of this request. The default data source for each data type will be read, then aggregated as specified in aggregate(DataType, DataType).

Returns
List<DataType> the input data types for aggregation, empty if none

public long getBucketDuration (TimeUnit timeUnit)

Returns the bucket duration for this request in the given time unit.

Parameters
timeUnit TimeUnit
Returns
long

public int getBucketType ()

Returns the bucket type for data aggregation for this request.

Returns
int

public List<DataSource> getDataSources ()

Returns the data sources that should be read in this request.

Returns
List<DataSource> all specified data sources, empty if none

public List<DataType> getDataTypes ()

Returns the data types for which default data sources should be read in this request.

Returns
List<DataType> all specified data types, empty if none

public long getEndTime (TimeUnit timeUnit)

Returns the end time for our query, in the specified time unit

Parameters
timeUnit TimeUnit
Returns
long

public List<Integer> getFilteredDataQualityStandards ()

Returns the list of data quality standards which will restrict the data sources used in this query. If the list is empty all data sources will be included.

Returns
List<Integer>

public int getLimit ()

Returns the max number of data points to return in the result. If specified, only the latest data points up to the given limit will be read.

Returns
int the query limit, or NO_LIMIT if none

public long getStartTime (TimeUnit timeUnit)

Returns the start time for our query, in the specified time unit

Parameters
timeUnit TimeUnit
Returns
long

public int hashCode ()

Returns
int

public String toString ()

Returns
String

public void writeToParcel (Parcel dest, int flags)

Parameters
dest Parcel
flags int