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 functions

operator Boolean

Checks whether the aggregation result contains a metric or not.

operator T?
<T : Any> get(metric: AggregateMetric<T>)

Retrieves a metric with given metric identifier.

Public properties

Set<DataOrigin>

Set of DataOrigins that contributed to the aggregation result.

Public functions

contains

Added in 1.1.0-alpha10
operator fun contains(metric: AggregateMetric<*>): Boolean

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
metric: AggregateMetric<*>

an aggregate metric identifier.

Returns
Boolean

whether given metric is set.

get

operator fun <T : Any> get(metric: AggregateMetric<T>): T?

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

Public properties

dataOrigins

Added in 1.1.0-alpha10
val dataOriginsSet<DataOrigin>

Set of DataOrigins that contributed to the aggregation result.