目录

ReadOptions

Class Info

public class ReadOptions

数据读取请求类,使用此请求可以指定要读取的数据类型以及聚合参数,读取请求需要设置时间范围,并允许以详细或汇总的方式读取数据。

构建ReadOptions查询详情数据,需要指定详情数据的时间区间(必填),一个或多个特定的DataType或DataCollector。

构建ReadOptions查询数据详情的示例代码如下:

  1. 构建ReadOptions读一个指定DataType(增量步数)的详情。
    示例代码如下:
    “Java”
    ReadOptions readOptions = new ReadOptions.Builder()
        .setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)
        .read(DataType.DT_CONTINUOUS_STEPS_DELTA)
        .build();
    “Kotlin”
    val readOptions = ReadOptions.Builder()
        .setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)
        .read(DataType.DT_CONTINUOUS_STEPS_DELTA)
        .build()
  2. 构建ReadOptions读取多个指定DataType(增量步数和身高)的详情。
    示例代码如下:
    “Java”
    ReadOptions readOptions = new ReadOptions.Builder()
        .setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)
        .read(DataType.DT_CONTINUOUS_STEPS_DELTA)
        .read(DataType.DT_INSTANTANEOUS_HEIGHT)
        .build();
    “Kotlin”
    val readOptions = ReadOptions.Builder()
        .setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)
        .read(DataType.DT_CONTINUOUS_STEPS_DELTA)
        .read(DataType.DT_INSTANTANEOUS_HEIGHT)
        .build()
  3. 构建ReadOptions读取指定DataCollector的详情。
    示例代码如下:
    “Java”
    ReadOptions readOptions = new ReadOptions.Builder()
        .setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)
        .read(dataCollectorDevices)
        .build();
    “Kotlin”
    val readOptions = ReadOptions.Builder()
        .setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)
        .read(dataCollectorDevices)
        .build()

构建ReadOptions查询汇总数据,需要指定汇总数据的时间区间(必填),汇总方式(必填),分组方式(必填)。

构建ReadOptions查询数据汇总的示例代码如下:
“Java”
ReadOptions readOptions = new ReadOptions.Builder()
    .setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)
    .polymerize(DataType.DT_CONTINUOUS_STEPS_DELTA, DataType.DT_CONTINUOUS_STEPS_TOTAL)
    .groupByTime(1, TimeUnit.HOURS)
    .build();
“Kotlin”
val readOptions = ReadOptions.Builder()
    .setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)
    .polymerize(DataType.DT_CONTINUOUS_STEPS_DELTA, DataType.DT_CONTINUOUS_STEPS_TOTAL)
    .groupByTime(1, TimeUnit.HOURS)
    .build()
  1. 调用查询运动健康数据接口,接口参数中的开始时间和结束时间均需大于2014年1月1号对应的UNIX时间戳。
  2. 调用查询运动健康数据接口,接口参数中的开始时间和结束时间之间的时间跨度不允许超过31天。

Nested Class Summary

Qualifier and Type

Class Name and Description

public static class

ReadOptions.Builder

ReadOptions的构造器。

Constant Summary

Type

Name

Description

int

NO_LIMIT

表示查询返回结果数据量无限制。

Public Method Summary

Qualifier and Type

Method Name and Description

List<DataCollector>

getDataCollectors()

获取要读取的数据采集器。

List<DataType>

getDataTypes()

获取要读取的数据类型。

long

getEndTime(TimeUnit timeUnit)

获取读取数据区间的结束时间。

long

getGroupPeriod(TimeUnit timeUnit)

获取数据的分组时长。

int

getGroupType()

获取分组的类型。

int

getPageSize()

获取结果分页的上限数量。

List<DataCollector>

getPolymerizedDataCollectors()

获取聚合后的数据采集器。

List<DataType>

getPolymerizedDataTypes()

获取聚合后的数据类型。

long

getStartTime(TimeUnit timeUnit)

获取读取数据区间的开始时间。

Constants

[h2]NO_LIMIT

Constant

public static final int NO_LIMIT

表示返回结果数据不分页。Constant Value: 0

Public Methods

[h2]getDataCollectors()

Method

public List<DataCollector> getDataCollectors()

获取要读取的数据采集器。

Returns

Type

Description

List<DataCollector>

获取要读取的数据采集器。

[h2]getDataTypes()

Method

public List<DataType> getDataTypes()

获取要读取的数据类型。

Returns

Type

Description

List<DataType>

获取要读取的数据类型。

[h2]getEndTime(TimeUnit timeUnit)

Method

public long getEndTime(TimeUnit timeUnit)

获取读取数据区间的结束时间。

Parameters

Name

Description

timeUnit

时间单位。

Returns

Type

Description

long

返回指定时间单位的结束时间。

[h2]getGroupPeriod(TimeUnit timeUnit)

Method

public long getGroupPeriod(TimeUnit timeUnit)

获取数据的分组时长。

Parameters

Name

Description

timeUnit

时间单位。

Returns

Type

Description

long

获取分组的持续时间。

[h2]getGroupType()

Method

public int getGroupType()

获取分组的类型。

Returns

Type

Description

int

获取分组的类型。

[h2]getPageSize()

Method

public int getPageSize()

获取结果分页的上限数量。

Returns

Type

Description

int

获取结果分页的上限数量。

[h2]getPolymerizedDataCollectors()

Method

public List<DataCollector> getPolymerizedDataCollectors()

获取聚合后的数据采集器。

Returns

Type

Description

List<DataCollector>

获取聚合后的数据采集器。

[h2]getPolymerizedDataTypes()

Method

public List<DataType> getPolymerizedDataTypes()

获取聚合后的数据类型。

Returns

Type

Description

List<DataType>

获取聚合后的数据类型。

[h2]getStartTime(TimeUnit timeUnit)

Method

public long getStartTime(TimeUnit timeUnit)

获取读取数据区间的开始时间。

Parameters

Name

Description

timeUnit

时间单位。

Returns

Type

Description

long

返回指定时间单位的开始时间。