LocalDataReadRequest

public class LocalDataReadRequest extends Object

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
Example usage for reading steps during an interval:
     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 LocalDataReadRequests. 

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

Inherited Method Summary

Constants

public static final int NO_LIMIT

Constant specifying no limit has been set.

Constant Value: 0

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

public long getStartTime (TimeUnit timeUnit)

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

public int hashCode ()

public String toString ()