Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in [U Extensions 7](https://developer.android.com/sdkExtensions) Summary: [Ctors](https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegment.Builder#pubctors) \| [Methods](https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegment.Builder#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegment.Builder#inhmethods)

# ExerciseSegment.Builder

*** ** * ** ***


`
public
static
final

class
ExerciseSegment.Builder
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.health.connect.datatypes.ExerciseSegment.Builder |

<br />

*** ** * ** ***

Builder class for `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegment`

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegment.Builder#Builder(java.time.Instant,%20java.time.Instant,%20int)(https://developer.android.com/reference/java/time/Instant startTime, https://developer.android.com/reference/java/time/Instant endTime, int segmentType) ` |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegment` | ` https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegment.Builder#build()() ` Sets the number repetitions to the current segment. |
| ` https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegment.Builder` | ` https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegment.Builder#clearRateOfPerceivedExertion()() ` Clears the rate of perceived exertion for this exercise segment. |
| ` https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegment.Builder` | ` https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegment.Builder#clearSetIndex()() ` Clears the set index for this exercise segment. |
| ` https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegment.Builder` | ` https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegment.Builder#clearWeight()() ` Clears the weight for this exercise segment. |
| ` https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegment.Builder` | ` https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegment.Builder#setRateOfPerceivedExertion(float)(float rateOfPerceivedExertion) ` Sets rate of perceived exertion (RPE) used during the exercise segment. |
| ` https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegment.Builder` | ` https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegment.Builder#setRepetitionsCount(int)(int repetitionsCount) ` Sets the number of repetitions to the current segment. |
| ` https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegment.Builder` | ` https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegment.Builder#setSetIndex(int)(int setIndex) ` Sets the set index for this exercise segment. |
| ` https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegment.Builder` | ` https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegment.Builder#setWeight(android.health.connect.datatypes.units.Mass)(https://developer.android.com/reference/android/health/connect/datatypes/units/Mass weight) ` Sets the weight associated with this exercise segment. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Public constructors

### Builder

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in [U Extensions 7](https://developer.android.com/sdkExtensions)

```
public Builder (Instant startTime, 
                Instant endTime, 
                int segmentType)
```

<br />

<br />

| Parameters ||
|---|---|
| `startTime` | `Instant`: This value cannot be `null`. <br /> |
| `endTime` | `Instant`: This value cannot be `null`. <br /> |
| `segmentType` | `int`: Value is one of the following: - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_UNKNOWN` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_BARBELL_SHOULDER_PRESS` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_BENCH_SIT_UP` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_BIKING` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_BIKING_STATIONARY` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_DUMBBELL_CURL_LEFT_ARM` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_DUMBBELL_CURL_RIGHT_ARM` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_DUMBBELL_FRONT_RAISE` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_DUMBBELL_LATERAL_RAISE` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_DUMBBELL_TRICEPS_EXTENSION_LEFT_ARM` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_DUMBBELL_TRICEPS_EXTENSION_RIGHT_ARM` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_DUMBBELL_TRICEPS_EXTENSION_TWO_ARM` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_FORWARD_TWIST` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_ELLIPTICAL` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_HIGH_INTENSITY_INTERVAL_TRAINING` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_PILATES` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_ROWING_MACHINE` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_RUNNING` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_RUNNING_TREADMILL` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_STAIR_CLIMBING` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_STAIR_CLIMBING_MACHINE` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_STRETCHING` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_SWIMMING_OPEN_WATER` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_SWIMMING_POOL` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_UPPER_TWIST` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_WALKING` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_WEIGHTLIFTING` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_WHEELCHAIR` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_OTHER_WORKOUT` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_YOGA` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_ARM_CURL` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_BACK_EXTENSION` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_BALL_SLAM` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_BENCH_PRESS` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_BURPEE` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_CRUNCH` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_DEADLIFT` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_DOUBLE_ARM_TRICEPS_EXTENSION` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_DUMBBELL_ROW` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_FRONT_RAISE` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_HIP_THRUST` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_HULA_HOOP` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_JUMPING_JACK` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_JUMP_ROPE` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_KETTLEBELL_SWING` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_LATERAL_RAISE` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_LAT_PULL_DOWN` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_LEG_CURL` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_LEG_EXTENSION` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_LEG_PRESS` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_LEG_RAISE` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_LUNGE` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_MOUNTAIN_CLIMBER` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_PLANK` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_PULL_UP` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_PUNCH` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_SHOULDER_PRESS` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_SINGLE_ARM_TRICEPS_EXTENSION` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_SIT_UP` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_SQUAT` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_SWIMMING_FREESTYLE` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_SWIMMING_BACKSTROKE` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_SWIMMING_BREASTSTROKE` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_SWIMMING_BUTTERFLY` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_SWIMMING_MIXED` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_SWIMMING_OTHER` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_REST` - `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegmentType#EXERCISE_SEGMENT_TYPE_PAUSE` |

## Public methods

### build

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in [U Extensions 7](https://developer.android.com/sdkExtensions)

```
public ExerciseSegment build ()
```

Sets the number repetitions to the current segment. Returns `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegment`
instance.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegment` | This value cannot be `null`. <br /> |

### clearRateOfPerceivedExertion

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)  
Also in [U Extensions 19](https://developer.android.com/sdkExtensions)

```
public ExerciseSegment.Builder clearRateOfPerceivedExertion ()
```

Clears the rate of perceived exertion for this exercise segment.

Returns builder instance with rate of perceived exertion unset.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegment.Builder` | This value cannot be `null`. <br /> |

### clearSetIndex

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)  
Also in [U Extensions 19](https://developer.android.com/sdkExtensions)

```
public ExerciseSegment.Builder clearSetIndex ()
```

Clears the set index for this exercise segment.

Returns builder instance with set index unset.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegment.Builder` | This value cannot be `null`. <br /> |

### clearWeight

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)  
Also in [U Extensions 19](https://developer.android.com/sdkExtensions)

```
public ExerciseSegment.Builder clearWeight ()
```

Clears the weight for this exercise segment.

Returns builder instance with weight unset.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegment.Builder` | This value cannot be `null`. <br /> |

### setRateOfPerceivedExertion

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)  
Also in [U Extensions 19](https://developer.android.com/sdkExtensions)

```
public ExerciseSegment.Builder setRateOfPerceivedExertion (float rateOfPerceivedExertion)
```

Sets rate of perceived exertion (RPE) used during the exercise segment.

Values correspond to the Borg CR10 RPE scale and must be in the range 0 to 10
inclusive. 0: No exertion (at rest) 1: Very light 2-3: Light 4-5: Moderate 6-7: Hard 8-9:
Very hard 10: Maximum effort

Returns builder instance with rate of perceived exertion set.

<br />

| Parameters ||
|---|---|
| `rateOfPerceivedExertion` | `float`: Value is between 0.0f and 10.0f inclusive <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegment.Builder` | This value cannot be `null`. <br /> |

### setRepetitionsCount

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in [U Extensions 7](https://developer.android.com/sdkExtensions)

```
public ExerciseSegment.Builder setRepetitionsCount (int repetitionsCount)
```

Sets the number of repetitions to the current segment. Returns builder instance with
repetitions count set.

<br />

| Parameters ||
|---|---|
| `repetitionsCount` | `int`: Value is 0 or greater <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegment.Builder` | This value cannot be `null`. <br /> |

### setSetIndex

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)  
Also in [U Extensions 19](https://developer.android.com/sdkExtensions)

```
public ExerciseSegment.Builder setSetIndex (int setIndex)
```

Sets the set index for this exercise segment.

The set index must be a non-negative integer, and should start at zero.

Set index represents the position of this set relative to other sets in the session.
For instance, if an exercise has three sets, they will have setIndex values of 0, 1, and
2 respectively.

Multiple segments may be part of a single set, for example if a collection of
activities are considered to be a single set, in which case those segments would have the
same set index.

The set index is may also go back to zero in a single `ExerciseSession`. For
example, if three sets of one activity are completed followed by three sets of another,
setIndex values of 0, 1, 2, 0, 1, 2 would be expected for those segments.

Returns builder instance with set index set.

<br />

| Parameters ||
|---|---|
| `setIndex` | `int`: Value is 0 or greater <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegment.Builder` | This value cannot be `null`. <br /> |

### setWeight

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)  
Also in [U Extensions 19](https://developer.android.com/sdkExtensions)

```
public ExerciseSegment.Builder setWeight (Mass weight)
```

Sets the weight associated with this exercise segment.

Weight must be at least zero and not more than 2500kg.

Returns builder instance with weight set.

<br />

| Parameters ||
|---|---|
| `weight` | `Mass`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/health/connect/datatypes/ExerciseSegment.Builder` | This value cannot be `null`. <br /> |