# ExerciseConfig.Builder

Artifact: [androidx.health:health-services-client](https://developer.android.com/jetpack/androidx/releases/health) [View Source](https://cs.android.com/search?q=file:androidx/health/services/client/data/ExerciseConfig.kt+class:androidx.health.services.client.data.ExerciseConfig.Builder) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/health#1.0.0)

*** ** * ** ***


```
public final class ExerciseConfig.Builder
```

<br />

*** ** * ** ***

Builder for `https://developer.android.com/reference/androidx/health/services/client/data/ExerciseConfig` instances.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/health/services/client/data/ExerciseConfig.Builder#Builder(androidx.health.services.client.data.ExerciseType)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/data/ExerciseType exerciseType)` |

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/data/ExerciseConfig` | `https://developer.android.com/reference/androidx/health/services/client/data/ExerciseConfig.Builder#build()()` Returns the built `https://developer.android.com/reference/androidx/health/services/client/data/ExerciseConfig`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/data/ExerciseConfig.Builder` | `https://developer.android.com/reference/androidx/health/services/client/data/ExerciseConfig.Builder#setBatchingModeOverrides(kotlin.collections.Set)( @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/services/client/data/BatchingMode> batchingModeOverrides )` Sets the `https://developer.android.com/reference/androidx/health/services/client/data/BatchingMode` overrides for the ongoing exercise. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/data/ExerciseConfig.Builder` | `https://developer.android.com/reference/androidx/health/services/client/data/ExerciseConfig.Builder#setDataTypes(kotlin.collections.Set)( @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/services/client/data/DataType<@https://developer.android.com/reference/androidx/annotation/NonNull ?, @https://developer.android.com/reference/androidx/annotation/NonNull ?>> dataTypes )` Sets the requested `https://developer.android.com/reference/androidx/health/services/client/data/DataType`s that should be tracked during this exercise. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/data/ExerciseConfig.Builder` | `https://developer.android.com/reference/androidx/health/services/client/data/ExerciseConfig.Builder#setDebouncedGoals(kotlin.collections.List)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/data/DebouncedGoal<@https://developer.android.com/reference/androidx/annotation/NonNull ?>> debouncedGoals )` Sets `https://developer.android.com/reference/androidx/health/services/client/data/DebouncedGoal`s specified for this exercise. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/data/ExerciseConfig.Builder` | `https://developer.android.com/reference/androidx/health/services/client/data/ExerciseConfig.Builder#setExerciseEventTypes(kotlin.collections.Set)( @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/services/client/data/ExerciseEventType<@https://developer.android.com/reference/androidx/annotation/NonNull ?>> exerciseEventTypes )` Sets the `https://developer.android.com/reference/androidx/health/services/client/data/ExerciseEventType`s that should be tracked for this exercise. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/data/ExerciseConfig.Builder` | `https://developer.android.com/reference/androidx/health/services/client/data/ExerciseConfig.Builder#setExerciseGoals(kotlin.collections.List)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/data/ExerciseGoal<@https://developer.android.com/reference/androidx/annotation/NonNull ?>> exerciseGoals )` Sets `https://developer.android.com/reference/androidx/health/services/client/data/ExerciseGoal`s specified for this exercise. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/data/ExerciseConfig.Builder` | `https://developer.android.com/reference/androidx/health/services/client/data/ExerciseConfig.Builder#setExerciseParams(android.os.Bundle)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/Bundle.html exerciseParams)` Sets additional OEM specific parameters for the current exercise. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/data/ExerciseConfig.Builder` | `https://developer.android.com/reference/androidx/health/services/client/data/ExerciseConfig.Builder#setExerciseTypeConfig(androidx.health.services.client.data.ExerciseTypeConfig)(https://developer.android.com/reference/androidx/health/services/client/data/ExerciseTypeConfig exerciseTypeConfig)` Sets the `https://developer.android.com/reference/androidx/health/services/client/data/ExerciseTypeConfig` which are configurable attributes for the ongoing exercise. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/data/ExerciseConfig.Builder` | `https://developer.android.com/reference/androidx/health/services/client/data/ExerciseConfig.Builder#setIsAutoPauseAndResumeEnabled(kotlin.Boolean)(boolean isAutoPauseAndResumeEnabled)` Sets whether auto pause and auto resume should be enabled for this exercise. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/data/ExerciseConfig.Builder` | `https://developer.android.com/reference/androidx/health/services/client/data/ExerciseConfig.Builder#setIsGpsEnabled(kotlin.Boolean)(boolean isGpsEnabled)` Sets whether GPS will be used for this exercise. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/data/ExerciseConfig.Builder` | `https://developer.android.com/reference/androidx/health/services/client/data/ExerciseConfig.Builder#setSwimmingPoolLengthMeters(kotlin.Float)(float swimmingPoolLength)` Sets the swimming pool length (in m). |

## Public constructors

### Builder

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

```
public Builder(@NonNull ExerciseType exerciseType)
```

## Public methods

### build

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

```
public final @NonNull ExerciseConfig build()
```

Returns the built `https://developer.android.com/reference/androidx/health/services/client/data/ExerciseConfig`.

### setBatchingModeOverrides

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

```
public final @NonNull ExerciseConfig.Builder setBatchingModeOverrides(
    @NonNull Set<@NonNull BatchingMode> batchingModeOverrides
)
```

Sets the `https://developer.android.com/reference/androidx/health/services/client/data/BatchingMode` overrides for the ongoing exercise.

| Parameters |
|---|---|
| `@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/services/client/data/BatchingMode> batchingModeOverrides` | `https://developer.android.com/reference/androidx/health/services/client/data/BatchingMode` overrides |

### setDataTypes

```
public final @NonNull ExerciseConfig.Builder setDataTypes(
    @NonNull Set<@NonNull DataType<@NonNull ?, @NonNull ?>> dataTypes
)
```

Sets the requested `https://developer.android.com/reference/androidx/health/services/client/data/DataType`s that should be tracked during this exercise. If not explicitly called, a default set of `https://developer.android.com/reference/androidx/health/services/client/data/DataType`s will be chosen based on the `https://developer.android.com/reference/androidx/health/services/client/data/ExerciseType`.

| Parameters |
|---|---|
| `@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/services/client/data/DataType<@https://developer.android.com/reference/androidx/annotation/NonNull ?, @https://developer.android.com/reference/androidx/annotation/NonNull ?>> dataTypes` | set of `https://developer.android.com/reference/androidx/health/services/client/data/DataType`s (`https://developer.android.com/reference/androidx/health/services/client/data/AggregateDataType` or `https://developer.android.com/reference/androidx/health/services/client/data/DeltaDataType`) to track during this exercise |

### setDebouncedGoals

```
public final @NonNull ExerciseConfig.Builder setDebouncedGoals(
    @NonNull List<@NonNull DebouncedGoal<@NonNull ?>> debouncedGoals
)
```

Sets `https://developer.android.com/reference/androidx/health/services/client/data/DebouncedGoal`s specified for this exercise.

`https://developer.android.com/reference/androidx/health/services/client/data/DataType`s in `https://developer.android.com/reference/androidx/health/services/client/data/DebouncedGoal`s must also be tracked. Only one debounced goal per data type can be tracked in an exercise. If multiple debuonced goals of the same data type, only the last one will be applied.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/data/DebouncedGoal<@https://developer.android.com/reference/androidx/annotation/NonNull ?>> debouncedGoals` | the list of DeoubcendGoals to begin the exercise with |

### setExerciseEventTypes

```
public final @NonNull ExerciseConfig.Builder setExerciseEventTypes(
    @NonNull Set<@NonNull ExerciseEventType<@NonNull ?>> exerciseEventTypes
)
```

Sets the `https://developer.android.com/reference/androidx/health/services/client/data/ExerciseEventType`s that should be tracked for this exercise.

| Parameters |
|---|---|
| `@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/services/client/data/ExerciseEventType<@https://developer.android.com/reference/androidx/annotation/NonNull ?>> exerciseEventTypes` | the set of `https://developer.android.com/reference/androidx/health/services/client/data/ExerciseEventType`s to begin the exercise with |

### setExerciseGoals

```
public final @NonNull ExerciseConfig.Builder setExerciseGoals(
    @NonNull List<@NonNull ExerciseGoal<@NonNull ?>> exerciseGoals
)
```

Sets `https://developer.android.com/reference/androidx/health/services/client/data/ExerciseGoal`s specified for this exercise.

`https://developer.android.com/reference/androidx/health/services/client/data/DataType`s in `https://developer.android.com/reference/androidx/health/services/client/data/ExerciseGoal`s must also be tracked (i.e. provided to `https://developer.android.com/reference/androidx/health/services/client/data/ExerciseConfig.Builder#setDataTypes(kotlin.collections.Set)`) in some form. For example, an `https://developer.android.com/reference/androidx/health/services/client/data/ExerciseGoal` for `https://developer.android.com/reference/androidx/health/services/client/data/DataType#STEPS_TOTAL()` requires that either or both of `https://developer.android.com/reference/androidx/health/services/client/data/DataType#STEPS_TOTAL()` / `https://developer.android.com/reference/androidx/health/services/client/data/DataType#STEPS()` be passed into `https://developer.android.com/reference/androidx/health/services/client/data/ExerciseConfig.Builder#setDataTypes(kotlin.collections.Set)`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/data/ExerciseGoal<@https://developer.android.com/reference/androidx/annotation/NonNull ?>> exerciseGoals` | the list of `https://developer.android.com/reference/androidx/health/services/client/data/ExerciseGoal`s to begin the exercise with |

### setExerciseParams

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

```
public final @NonNull ExerciseConfig.Builder setExerciseParams(@NonNull Bundle exerciseParams)
```

Sets additional OEM specific parameters for the current exercise. Intended to be used by OEMs or apps working closely with them.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/Bundle.html exerciseParams` | `https://developer.android.com/reference/android/os/Bundle.html` containing OEM specific parameters |

### setExerciseTypeConfig

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

```
public final @NonNull ExerciseConfig.Builder setExerciseTypeConfig(ExerciseTypeConfig exerciseTypeConfig)
```

Sets the `https://developer.android.com/reference/androidx/health/services/client/data/ExerciseTypeConfig` which are configurable attributes for the ongoing exercise.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/health/services/client/data/ExerciseTypeConfig exerciseTypeConfig` | `https://developer.android.com/reference/androidx/health/services/client/data/ExerciseTypeConfig` specifying active exercise type configurations |

### setIsAutoPauseAndResumeEnabled

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

```
public final @NonNull ExerciseConfig.Builder setIsAutoPauseAndResumeEnabled(boolean isAutoPauseAndResumeEnabled)
```

Sets whether auto pause and auto resume should be enabled for this exercise. If not set, auto-pause is disabled by default.

| Parameters |
|---|---|
| `boolean isAutoPauseAndResumeEnabled` | if true, exercise will automatically pause and resume |

### setIsGpsEnabled

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

```
public final @NonNull ExerciseConfig.Builder setIsGpsEnabled(boolean isGpsEnabled)
```

Sets whether GPS will be used for this exercise. If not set, it's disabled by default.

If `https://developer.android.com/reference/androidx/health/services/client/data/DataType#LOCATION()` is among the data types requested for the exercise, GPS usage MUST be enabled. Enabling GPS will improve data generation for types like distance and speed.

If no data type is specified in the configuration, WHS provides all data types supported for the exercise. In this case, if `https://developer.android.com/reference/androidx/health/services/client/data/DataType#LOCATION()` is among the supported data types for the exercise but GPS usage is disabled (i.e. `https://developer.android.com/reference/androidx/health/services/client/data/ExerciseConfig.Builder#setIsGpsEnabled(kotlin.Boolean)` is `false`, then `https://developer.android.com/reference/androidx/health/services/client/ExerciseClient#startExerciseAsync(androidx.health.services.client.data.ExerciseConfig)` will fail.

| Parameters |
|---|---|
| `boolean isGpsEnabled` | if true, GPS will be enabled for this exercise |

### setSwimmingPoolLengthMeters

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

```
public final @NonNull ExerciseConfig.Builder setSwimmingPoolLengthMeters(float swimmingPoolLength)
```

Sets the swimming pool length (in m).