# ExerciseConfig.Builder

# 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)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/health/services/client/data/ExerciseConfig.Builder "View this page in Java")

<br />

```
class ExerciseConfig.Builder
```

<br />

*** ** * ** ***

Builder for[ExerciseConfig](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ExerciseConfig)instances.

## Summary

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

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

```
Builder(exerciseType: ExerciseType)
```  

## Public functions

### build

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

```
fun build(): ExerciseConfig
```

Returns the built[ExerciseConfig](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ExerciseConfig).  

### setBatchingModeOverrides

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

```
fun setBatchingModeOverrides(batchingModeOverrides: Set<BatchingMode>): ExerciseConfig.Builder
```

Sets the[BatchingMode](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/BatchingMode)overrides for the ongoing exercise.  

|                                                                                                               Parameters                                                                                                               |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|
| `batchingModeOverrides: `[Set](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html)`<`[BatchingMode](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/BatchingMode)`>` | [BatchingMode](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/BatchingMode)overrides |

### setDataTypes

```
fun setDataTypes(dataTypes: Set<DataType<*, *>>): ExerciseConfig.Builder
```

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

|                                                                                                        Parameters                                                                                                        |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `dataTypes: `[Set](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html)`<`[DataType](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DataType)`<*, *>>` | set of[DataType](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DataType)s ([AggregateDataType](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/AggregateDataType)or[DeltaDataType](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DeltaDataType)) to track during this exercise |

### setDebouncedGoals

```
fun setDebouncedGoals(debouncedGoals: List<DebouncedGoal<*>>): ExerciseConfig.Builder
```

Sets[DebouncedGoal](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DebouncedGoal)s specified for this exercise.

[DataType](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DataType)s in[DebouncedGoal](https://developer.android.com/reference/kotlin/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                                                                                                               |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------|
| `debouncedGoals: `[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<`[DebouncedGoal](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DebouncedGoal)`<*>>` | the list of DeoubcendGoals to begin the exercise with |

### setExerciseEventTypes

```
fun setExerciseEventTypes(exerciseEventTypes: Set<ExerciseEventType<*>>): ExerciseConfig.Builder
```

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

|                                                                                                                    Parameters                                                                                                                    |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `exerciseEventTypes: `[Set](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html)`<`[ExerciseEventType](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ExerciseEventType)`<*>>` | the set of[ExerciseEventType](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ExerciseEventType)s to begin the exercise with |

### setExerciseGoals

```
fun setExerciseGoals(exerciseGoals: List<ExerciseGoal<*>>): ExerciseConfig.Builder
```

Sets[ExerciseGoal](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ExerciseGoal)s specified for this exercise.

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

|                                                                                                             Parameters                                                                                                              |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|
| `exerciseGoals: `[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<`[ExerciseGoal](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ExerciseGoal)`<*>>` | the list of[ExerciseGoal](https://developer.android.com/reference/kotlin/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)  

```
fun setExerciseParams(exerciseParams: Bundle): ExerciseConfig.Builder
```

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

|                                         Parameters                                         |
|--------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------|
| `exerciseParams: `[Bundle](https://developer.android.com/reference/android/os/Bundle.html) | [Bundle](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)  

```
fun setExerciseTypeConfig(exerciseTypeConfig: ExerciseTypeConfig?): ExerciseConfig.Builder
```

Sets the[ExerciseTypeConfig](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ExerciseTypeConfig)which are configurable attributes for the ongoing exercise.  

|                                                                      Parameters                                                                       |
|-------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `exerciseTypeConfig: `[ExerciseTypeConfig](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ExerciseTypeConfig)`?` | [ExerciseTypeConfig](https://developer.android.com/reference/kotlin/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)  

```
fun setIsAutoPauseAndResumeEnabled(isAutoPauseAndResumeEnabled: Boolean): ExerciseConfig.Builder
```

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

|                                                     Parameters                                                     |
|--------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------|
| `isAutoPauseAndResumeEnabled: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | 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)  

```
fun setIsGpsEnabled(isGpsEnabled: Boolean): ExerciseConfig.Builder
```

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

If[DataType.LOCATION](https://developer.android.com/reference/kotlin/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[DataType.LOCATION](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DataType#LOCATION())is among the supported data types for the exercise but GPS usage is disabled (i.e.[isGpsEnabled](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ExerciseConfig.Builder#setIsGpsEnabled(kotlin.Boolean))is`false`, then[ExerciseClient.startExerciseAsync](https://developer.android.com/reference/kotlin/androidx/health/services/client/ExerciseClient#startExerciseAsync(androidx.health.services.client.data.ExerciseConfig))will fail.  

|                                             Parameters                                              |
|-----------------------------------------------------------------------------------------------------|------------------------------------------------|
| `isGpsEnabled: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | 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)  

```
fun setSwimmingPoolLengthMeters(swimmingPoolLength: Float): ExerciseConfig.Builder
```

Sets the swimming pool length (in m).