Summary: Nested Classes | Constants | Inherited Constants | Fields | Methods | Inherited Methods | [Expand All]
public class

# DataReadRequest

extends Object
implements SafeParcelable

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 com.google.android.gms.common.internal.safeparcel.SafeParcelable
String | NULL |
From interface android.os.Parcelable
int | CONTENTS_FILE_DESCRIPTOR |
int | PARCELABLE_WRITE_RETURN_VALUE |

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
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
Object | clone()
boolean | equals(Object arg0)
void | finalize()
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)
final void | wait()
From interface android.os.Parcelable
abstract int | describeContents()
abstract void | writeToParcel(Parcel arg0, int arg1)

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

#### 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

- 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

- 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

- 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.

#### public int getBucketType ()

Returns the bucket type for data aggregation for this request.

#### public List<DataSource> getDataSources ()

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

##### Returns

- 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

- all specified data types, empty if none

#### public long getEndTime (TimeUnit timeUnit)

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

#### 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

- 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

#### public int hashCode ()

#### public String toString ()

#### public void writeToParcel (Parcel dest, int flags)