目录

ActivityRecordReadOptions

Class Info

public class ActivityRecordReadOptions

Request parameter for reading activity records from Health Service Kit.

Sample code for reading activity records:
Java
// Note that startTime and endTime respectively indicate the start time and end time of the activity record to be read. You can define them by yourself.
ActivityRecordReadOptions readOption = new ActivityRecordReadOptions.Builder()
    .setTimeInterval(startTime, endTime, TimeUnit.MILLISECONDS)
    .readActivityRecordsFromAllApps()
    .read(DataType.DT_CONTINUOUS_STEPS_DELTA)
    .build();
Kotlin
// Note that startTime and endTime respectively indicate the start time and end time of the activity record to be read. You can define them by yourself.
val readRequest = ActivityRecordReadOptions.Builder()
    .setTimeInterval(startTime, endTime, TimeUnit.MILLISECONDS)
    .readActivityRecordsFromAllApps()
    .read(DataType.DT_CONTINUOUS_STEPS_DELTA)
    .build()
  1. The start time and end time for querying activity records must be later than the UNIX timestamp corresponding to January 1, 2014.
  2. The start time and end time for querying cannot span over 31 days.

Nested Class Summary

Qualifier and Type

Class Name and Description

public static class

ActivityRecordReadOptions.Builder

Builder for ActivityRecordReadOptions.

Public Method Summary

Qualifier and Type

Method Name and Description

List<DataType>

getDataTypes()

Obtains the data types to be read in the current request.

long

getEndTime(TimeUnit timeUnit)

Obtains the end time of the data to be read.

List<String>

getRemoveApplications()

Obtains the package names of all excluded apps.

long

getStartTime(TimeUnit timeUnit)

Obtains the start time of the data to be read.

boolean

isAllAppsSelected()

Checks whether the data to be read includes the activity records of all apps.

List<Integer>

getActivityTypeIdList()

Obtains the activity types of an activity record to be read in the current request.

Public Methods

[h2]getDataTypes()

Method

public List<DataType> getDataTypes()

Obtains the data types to be read in the current request.

Returns

Type

Description

List<DataType>

List of data types to be read. If none has been specified, the returned list will be empty.

[h2]getEndTime(TimeUnit timeUnit)

Method

public long getEndTime(TimeUnit timeUnit)

Obtains the end time of the data to be read.

Parameters

Name

Description

timeUnit

Time unit.

Returns

Type

Description

long

End time of the data to be read.

[h2]getRemoveApplications()

Method

public List<String> getRemoveApplications()

Obtains the package names of all excluded apps.

Returns

Type

Description

List<String>

List of package names of all excluded apps. If none has been specified, the returned list will be empty.

[h2]getStartTime(TimeUnit timeUnit)

Method

public long getStartTime(TimeUnit timeUnit)

Obtains the start time of the data to be read.

Parameters

Name

Description

timeUnit

Time unit.

Returns

Type

Description

long

Start time.

[h2]isAllAppsSelected()

Method

public boolean isAllAppsSelected()

Checks whether the data to be read includes the activity records of all apps.

Returns

Type

Description

boolean

Whether the data to be read includes the activity records of all apps.

[h2]getActivityTypeIdList()

Method

public List<Integer> getActivityTypeIdList

Obtains the activity types of an activity record to be read in the current request.

Returns

Type

Description

List<Integer>

List of activity types to be read.