Request for reading data from the Recording API on mobile. 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 together.
For requesting detailed data, the request should specify:
- the time interval for the data
- at least one data type
new LocalDataReadRequest.Builder() .setTimeRange(startTime.getMillis(), endTime.getMillis(). TimeUnit.MILLISECONDS) .read(LocalDataType.TYPE_STEP_COUNT_DELTA) .build();
Apps can request to aggregate data bucketed by time
.
Apps should also specify at least one input data type to aggregate.
The aggregation request should specify:
- time interval for the data
- at least one input data type to aggregate
Example usage for selecting steps for each hour:
new LocalDataReadRequest.Builder() .setTimeRange(startTime.getMillis(), endTime.getMillis(), TimeUnit.MILLISECONDS) .bucketByTime(1, TimeUnit.HOURS) .aggregate(LocalDataType.TYPE_STEP_COUNT_DELTA) .build();
Nested Class Summary
class | LocalDataReadRequest.Builder | Builder used to create new
LocalDataReadRequest s. |
Constant Summary
int | NO_LIMIT | Constant specifying no limit has been set. |
Public Method Summary
boolean | |
List<LocalDataType> |
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
LocalBucket
type for data aggregation for this request.
|
List<LocalDataType> |
getDataTypes()
Returns the data types that should be read in this request.
|
long | |
int |
getLimit()
Returns the max number of data points to return in the result.
|
long | |
int |
hashCode()
|
String |
toString()
|
Inherited Method Summary
Constants
public static final int NO_LIMIT
Constant specifying no limit has been set.
Public Methods
public boolean equals (Object that)
public List<LocalDataType> getAggregatedDataTypes ()
Returns all of the data types that will be read then aggregated as part of this
request. Each data type will be read, then aggregated as specified in
LocalDataReadRequest.Builder.aggregate(LocalDataType)
.
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 LocalBucket
type for data aggregation for this request.
public List<LocalDataType> getDataTypes ()
Returns the data types that 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