# AggregationResult

Artifact: [androidx.health.connect:connect-client](https://developer.android.com/jetpack/androidx/releases/health-connect) [View Source](https://cs.android.com/search?q=file:androidx/health/connect/client/aggregate/AggregationResult.kt+class:androidx.health.connect.client.aggregate.AggregationResult) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/health-connect#1.1.0)

*** ** * ** ***


```
public final class AggregationResult
```

<br />

*** ** * ** ***

Contains results of requested `https://developer.android.com/reference/androidx/health/connect/client/aggregate/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 |
|---|---|
| `https://developer.android.com/reference/androidx/health/connect/client/HealthConnectClient#aggregate(androidx.health.connect.client.request.AggregateRequest)` |   |

## Summary

| ### Public methods |
|---|---|
| `final boolean` | `https://developer.android.com/reference/androidx/health/connect/client/aggregate/AggregationResult#contains(androidx.health.connect.client.aggregate.AggregateMetric)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/aggregate/AggregateMetric<@https://developer.android.com/reference/androidx/annotation/NonNull ?> metric)` Checks whether the aggregation result contains a metric or not. |
| `boolean` | `https://developer.android.com/reference/androidx/health/connect/client/aggregate/AggregationResult#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `final T` | `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/health/connect/client/aggregate/AggregationResult#get(androidx.health.connect.client.aggregate.AggregateMetric)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/aggregate/AggregateMetric<@https://developer.android.com/reference/androidx/annotation/NonNull T> metric)` Retrieves a metric with given metric identifier. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Set.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/records/metadata/DataOrigin>` | `https://developer.android.com/reference/androidx/health/connect/client/aggregate/AggregationResult#getDataOrigins()()` Set of `https://developer.android.com/reference/androidx/health/connect/client/records/metadata/DataOrigin`s that contributed to the aggregation result. |
| `int` | `https://developer.android.com/reference/androidx/health/connect/client/aggregate/AggregationResult#hashCode()()` |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/health/connect/client/aggregate/AggregationResult#toString()()` |

## Public methods

### contains

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/health-connect#1.1.0)

```
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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/aggregate/AggregateMetric<@https://developer.android.com/reference/androidx/annotation/NonNull ?> metric` | an aggregate metric identifier. |

| Returns |
|---|---|
| `boolean` | whether given metric is set. |

### equals

```
public boolean equals(Object other)
```

### 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 |
|---|---|
| `https://developer.android.com/reference/androidx/health/connect/client/aggregate/AggregationResult#contains(androidx.health.connect.client.aggregate.AggregateMetric)` |   |

### getDataOrigins

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/health-connect#1.1.0)

```
public final @NonNull Set<@NonNull DataOrigin> getDataOrigins()
```

Set of `https://developer.android.com/reference/androidx/health/connect/client/records/metadata/DataOrigin`s that contributed to the aggregation result.

### hashCode

```
public int hashCode()
```

### toString

```
public @NonNull String toString()
```