public final class AggregationResult


Contains results of requested AggregateMetric.

To retrieve aggregate metrics:

val result = healthConnectClient.aggregate(
metrics = setOf(Steps.COUNT_TOTAL, Distance.DISTANCE_TOTAL)
)

val totalSteps = result[Steps.COUNT_TOTAL]
val totalDistance = result[Distance.DISTANCE_TOTAL]
See also
aggregate

Summary

Public methods

final boolean

Checks whether the aggregation result contains a metric or not.

final T
<T extends Object> get(@NonNull AggregateMetric<@NonNull T> metric)

Retrieves a metric with given metric identifier.

final @NonNull Set<@NonNull DataOrigin>

Set of DataOrigins that contributed to the aggregation result.

Public methods

contains

Added in 1.1.0-alpha10
public final boolean contains(@NonNull AggregateMetric<@NonNull ?> metric)

Checks whether the aggregation result contains a metric or not. If there is no relevant record that contribute to requested metric, the metric will not be provided.

Parameters
@NonNull AggregateMetric<@NonNull ?> metric

an aggregate metric identifier.

Returns
boolean

whether given metric is set.

get

public final T <T extends Object> get(@NonNull AggregateMetric<@NonNull T> metric)

Retrieves a metric with given metric identifier.

If there are no relevant records contributing to the requested metric, the metric will not be provided.

Returns
T

the value of the metric, or null if not set.

See also
contains

getDataOrigins

Added in 1.1.0-alpha10
public final @NonNull Set<@NonNull DataOrigingetDataOrigins()

Set of DataOrigins that contributed to the aggregation result.