# DistanceRecord

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/records/DistanceRecord.kt+class:androidx.health.connect.client.records.DistanceRecord) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/health-connect#1.1.0)

*** ** * ** ***


```
public final class DistanceRecord implements Record
```

<br />

*** ** * ** ***

Captures distance travelled by the user since the last reading. The total distance over an interval can be calculated by adding together all the values during the interval. The start time of each record should represent the start of the interval in which the distance was covered.

If break downs are preferred in scenario of a long workout, consider writing multiple distance records. The start time of each record should be equal to or greater than the end time of the previous record.

## Summary

| ### Public fields |
|---|---|
| `static final @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 https://developer.android.com/reference/androidx/health/connect/client/units/Length>` | `https://developer.android.com/reference/androidx/health/connect/client/records/DistanceRecord#DISTANCE_TOTAL()` Metric identifier to retrieve the total distance from `https://developer.android.com/reference/androidx/health/connect/client/aggregate/AggregationResult`. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/health/connect/client/records/DistanceRecord#DistanceRecord(java.time.Instant,java.time.ZoneOffset,java.time.Instant,java.time.ZoneOffset,androidx.health.connect.client.units.Length,androidx.health.connect.client.records.metadata.Metadata)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Instant.html startTime, https://developer.android.com/reference/java/time/ZoneOffset.html startZoneOffset, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Instant.html endTime, https://developer.android.com/reference/java/time/ZoneOffset.html endZoneOffset, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/units/Length distance, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/records/metadata/Metadata metadata )` |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/health/connect/client/records/DistanceRecord#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/units/Length` | `https://developer.android.com/reference/androidx/health/connect/client/records/DistanceRecord#getDistance()()` Distance in `https://developer.android.com/reference/androidx/health/connect/client/units/Length` unit. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Instant.html` | `https://developer.android.com/reference/androidx/health/connect/client/records/DistanceRecord#getEndTime()()` End time of the record. |
| `https://developer.android.com/reference/java/time/ZoneOffset.html` | `https://developer.android.com/reference/androidx/health/connect/client/records/DistanceRecord#getEndZoneOffset()()` User experienced zone offset at `https://developer.android.com/reference/androidx/health/connect/client/records/IntervalRecord#endTime()`, or null if unknown. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/records/metadata/Metadata` | `https://developer.android.com/reference/androidx/health/connect/client/records/DistanceRecord#getMetadata()()` Set of common metadata associated with the written record. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Instant.html` | `https://developer.android.com/reference/androidx/health/connect/client/records/DistanceRecord#getStartTime()()` Start time of the record. |
| `https://developer.android.com/reference/java/time/ZoneOffset.html` | `https://developer.android.com/reference/androidx/health/connect/client/records/DistanceRecord#getStartZoneOffset()()` User experienced zone offset at `https://developer.android.com/reference/androidx/health/connect/client/records/IntervalRecord#startTime()`, or null if unknown. |
| `int` | `https://developer.android.com/reference/androidx/health/connect/client/records/DistanceRecord#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/records/DistanceRecord#toString()()` |

## Public fields

### DISTANCE_TOTAL

```
public static final @NonNull AggregateMetric<@NonNull Length> DISTANCE_TOTAL
```

Metric identifier to retrieve the total distance from `https://developer.android.com/reference/androidx/health/connect/client/aggregate/AggregationResult`.

## Public constructors

### DistanceRecord

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

```
public DistanceRecord(
    @NonNull Instant startTime,
    ZoneOffset startZoneOffset,
    @NonNull Instant endTime,
    ZoneOffset endZoneOffset,
    @NonNull Length distance,
    @NonNull Metadata metadata
)
```

## Public methods

### equals

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

### getDistance

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

```
public final @NonNull Length getDistance()
```

Distance in `https://developer.android.com/reference/androidx/health/connect/client/units/Length` unit. Required field. Valid range: 0-1000000 meters.

### getEndTime

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

```
public @NonNull Instant getEndTime()
```

End time of the record.

### getEndZoneOffset

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

```
public ZoneOffset getEndZoneOffset()
```

User experienced zone offset at `https://developer.android.com/reference/androidx/health/connect/client/records/IntervalRecord#endTime()`, or null if unknown. Providing these will help history aggregations results stay consistent should user travel. Queries with user experienced time filters will assume system current zone offset if the information is absent.

### getMetadata

```
public @NonNull Metadata getMetadata()
```

Set of common metadata associated with the written record.

### getStartTime

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

```
public @NonNull Instant getStartTime()
```

Start time of the record.

### getStartZoneOffset

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

```
public ZoneOffset getStartZoneOffset()
```

User experienced zone offset at `https://developer.android.com/reference/androidx/health/connect/client/records/IntervalRecord#startTime()`, or null if unknown. Providing these will help history aggregations results stay consistent should user travel. Queries with user experienced time filters will assume system current zone offset if the information is absent.

### hashCode

```
public int hashCode()
```

### toString

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