ExerciseSessionRecord


public final class ExerciseSessionRecord implements Record


Captures any exercise a user does. This can be common fitness exercise like running or different sports.

Each record needs a start time and end time. Records don't need to be back-to-back or directly after each other, there can be gaps in between.

Example code demonstrate how to read exercise session:

import androidx.health.connect.client.readRecord
import androidx.health.connect.client.records.ExerciseSessionRecord
import androidx.health.connect.client.records.HeartRateRecord
import androidx.health.connect.client.request.ReadRecordsRequest
import androidx.health.connect.client.time.TimeRangeFilter

val response =
    healthConnectClient.readRecords(
        ReadRecordsRequest<ExerciseSessionRecord>(
            timeRangeFilter = TimeRangeFilter.between(startTime, endTime)
        )
    )
for (exerciseRecord in response.records) {
    // Process each exercise record
    // Optionally pull in with other data sources of the same time range.
    val heartRateRecords =
        healthConnectClient
            .readRecords(
                ReadRecordsRequest<HeartRateRecord>(
                    timeRangeFilter =
                        TimeRangeFilter.between(
                            exerciseRecord.startTime,
                            exerciseRecord.endTime
                        )
                )
            )
            .records
}

Summary

Constants

static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int

Can be used to represent any generic workout that does not fall into a specific category.

static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int

Public fields

static final @NonNull AggregateMetric<@NonNull Duration>

Metric identifier to retrieve the total exercise time from androidx.health.connect.client.aggregate.AggregationResult.

Public constructors

ExerciseSessionRecord(
    @NonNull Instant startTime,
    ZoneOffset startZoneOffset,
    @NonNull Instant endTime,
    ZoneOffset endZoneOffset,
    int exerciseType,
    String title,
    String notes,
    @NonNull Metadata metadata,
    @NonNull List<@NonNull ExerciseSegment> segments,
    @NonNull List<@NonNull ExerciseLap> laps,
    ExerciseRoute exerciseRoute,
    String plannedExerciseSessionId
)

Public methods

boolean
equals(Object other)
@NonNull Instant

End time of the record.

ZoneOffset

User experienced zone offset at endTime, or null if unknown.

final @NonNull ExerciseRouteResult

ExerciseRouteResult of the session.

final int

Type of exercise (e.g. walking, swimming).

final @NonNull List<@NonNull ExerciseLap>

ExerciseLaps of the session.

@NonNull Metadata

Set of common metadata associated with the written record.

final String

Additional notes for the session.

final String
final @NonNull List<@NonNull ExerciseSegment>

ExerciseSegments of the session.

@NonNull Instant

Start time of the record.

ZoneOffset

User experienced zone offset at startTime, or null if unknown.

final String

Title of the session.

int
@NonNull String

Constants

EXERCISE_TYPE_BADMINTON

public static final int EXERCISE_TYPE_BADMINTON = 2

EXERCISE_TYPE_BASEBALL

public static final int EXERCISE_TYPE_BASEBALL = 4

EXERCISE_TYPE_BASKETBALL

public static final int EXERCISE_TYPE_BASKETBALL = 5

EXERCISE_TYPE_BIKING

public static final int EXERCISE_TYPE_BIKING = 8

EXERCISE_TYPE_BIKING_STATIONARY

public static final int EXERCISE_TYPE_BIKING_STATIONARY = 9

EXERCISE_TYPE_BOOT_CAMP

public static final int EXERCISE_TYPE_BOOT_CAMP = 10

EXERCISE_TYPE_BOXING

public static final int EXERCISE_TYPE_BOXING = 11

EXERCISE_TYPE_CALISTHENICS

public static final int EXERCISE_TYPE_CALISTHENICS = 13

EXERCISE_TYPE_CRICKET

public static final int EXERCISE_TYPE_CRICKET = 14

EXERCISE_TYPE_DANCING

public static final int EXERCISE_TYPE_DANCING = 16

EXERCISE_TYPE_ELLIPTICAL

public static final int EXERCISE_TYPE_ELLIPTICAL = 25

EXERCISE_TYPE_EXERCISE_CLASS

public static final int EXERCISE_TYPE_EXERCISE_CLASS = 26

EXERCISE_TYPE_FENCING

public static final int EXERCISE_TYPE_FENCING = 27

EXERCISE_TYPE_FOOTBALL_AMERICAN

public static final int EXERCISE_TYPE_FOOTBALL_AMERICAN = 28

EXERCISE_TYPE_FOOTBALL_AUSTRALIAN

public static final int EXERCISE_TYPE_FOOTBALL_AUSTRALIAN = 29

EXERCISE_TYPE_FRISBEE_DISC

public static final int EXERCISE_TYPE_FRISBEE_DISC = 31

EXERCISE_TYPE_GOLF

public static final int EXERCISE_TYPE_GOLF = 32

EXERCISE_TYPE_GUIDED_BREATHING

public static final int EXERCISE_TYPE_GUIDED_BREATHING = 33

EXERCISE_TYPE_GYMNASTICS

public static final int EXERCISE_TYPE_GYMNASTICS = 34

EXERCISE_TYPE_HANDBALL

public static final int EXERCISE_TYPE_HANDBALL = 35

EXERCISE_TYPE_HIGH_INTENSITY_INTERVAL_TRAINING

public static final int EXERCISE_TYPE_HIGH_INTENSITY_INTERVAL_TRAINING = 36

EXERCISE_TYPE_HIKING

public static final int EXERCISE_TYPE_HIKING = 37

EXERCISE_TYPE_ICE_HOCKEY

public static final int EXERCISE_TYPE_ICE_HOCKEY = 38

EXERCISE_TYPE_ICE_SKATING

public static final int EXERCISE_TYPE_ICE_SKATING = 39

EXERCISE_TYPE_MARTIAL_ARTS

public static final int EXERCISE_TYPE_MARTIAL_ARTS = 44

EXERCISE_TYPE_OTHER_WORKOUT

public static final int EXERCISE_TYPE_OTHER_WORKOUT = 0

Can be used to represent any generic workout that does not fall into a specific category. Any unknown new value definition will also fall automatically into EXERCISE_TYPE_OTHER_WORKOUT.

Next Id: 84.

EXERCISE_TYPE_PADDLING

public static final int EXERCISE_TYPE_PADDLING = 46

EXERCISE_TYPE_PARAGLIDING

public static final int EXERCISE_TYPE_PARAGLIDING = 47

EXERCISE_TYPE_PILATES

public static final int EXERCISE_TYPE_PILATES = 48

EXERCISE_TYPE_RACQUETBALL

public static final int EXERCISE_TYPE_RACQUETBALL = 50

EXERCISE_TYPE_ROCK_CLIMBING

public static final int EXERCISE_TYPE_ROCK_CLIMBING = 51

EXERCISE_TYPE_ROLLER_HOCKEY

public static final int EXERCISE_TYPE_ROLLER_HOCKEY = 52

EXERCISE_TYPE_ROWING

public static final int EXERCISE_TYPE_ROWING = 53

EXERCISE_TYPE_ROWING_MACHINE

public static final int EXERCISE_TYPE_ROWING_MACHINE = 54

EXERCISE_TYPE_RUGBY

public static final int EXERCISE_TYPE_RUGBY = 55

EXERCISE_TYPE_RUNNING

public static final int EXERCISE_TYPE_RUNNING = 56

EXERCISE_TYPE_RUNNING_TREADMILL

public static final int EXERCISE_TYPE_RUNNING_TREADMILL = 57

EXERCISE_TYPE_SAILING

public static final int EXERCISE_TYPE_SAILING = 58

EXERCISE_TYPE_SCUBA_DIVING

public static final int EXERCISE_TYPE_SCUBA_DIVING = 59

EXERCISE_TYPE_SKATING

public static final int EXERCISE_TYPE_SKATING = 60

EXERCISE_TYPE_SKIING

public static final int EXERCISE_TYPE_SKIING = 61

EXERCISE_TYPE_SNOWBOARDING

public static final int EXERCISE_TYPE_SNOWBOARDING = 62

EXERCISE_TYPE_SNOWSHOEING

public static final int EXERCISE_TYPE_SNOWSHOEING = 63

EXERCISE_TYPE_SOCCER

public static final int EXERCISE_TYPE_SOCCER = 64

EXERCISE_TYPE_SOFTBALL

public static final int EXERCISE_TYPE_SOFTBALL = 65

EXERCISE_TYPE_SQUASH

public static final int EXERCISE_TYPE_SQUASH = 66

EXERCISE_TYPE_STAIR_CLIMBING

public static final int EXERCISE_TYPE_STAIR_CLIMBING = 68

EXERCISE_TYPE_STAIR_CLIMBING_MACHINE

public static final int EXERCISE_TYPE_STAIR_CLIMBING_MACHINE = 69

EXERCISE_TYPE_STRENGTH_TRAINING

public static final int EXERCISE_TYPE_STRENGTH_TRAINING = 70

EXERCISE_TYPE_STRETCHING

public static final int EXERCISE_TYPE_STRETCHING = 71

EXERCISE_TYPE_SURFING

public static final int EXERCISE_TYPE_SURFING = 72

EXERCISE_TYPE_SWIMMING_OPEN_WATER

public static final int EXERCISE_TYPE_SWIMMING_OPEN_WATER = 73

EXERCISE_TYPE_SWIMMING_POOL

public static final int EXERCISE_TYPE_SWIMMING_POOL = 74

EXERCISE_TYPE_TABLE_TENNIS

public static final int EXERCISE_TYPE_TABLE_TENNIS = 75

EXERCISE_TYPE_TENNIS

public static final int EXERCISE_TYPE_TENNIS = 76

EXERCISE_TYPE_VOLLEYBALL

public static final int EXERCISE_TYPE_VOLLEYBALL = 78

EXERCISE_TYPE_WALKING

public static final int EXERCISE_TYPE_WALKING = 79

EXERCISE_TYPE_WATER_POLO

public static final int EXERCISE_TYPE_WATER_POLO = 80

EXERCISE_TYPE_WEIGHTLIFTING

public static final int EXERCISE_TYPE_WEIGHTLIFTING = 81

EXERCISE_TYPE_WHEELCHAIR

public static final int EXERCISE_TYPE_WHEELCHAIR = 82

EXERCISE_TYPE_YOGA

public static final int EXERCISE_TYPE_YOGA = 83

Public fields

EXERCISE_DURATION_TOTAL

public static final @NonNull AggregateMetric<@NonNull DurationEXERCISE_DURATION_TOTAL

Metric identifier to retrieve the total exercise time from androidx.health.connect.client.aggregate.AggregationResult.

Public constructors

ExerciseSessionRecord

Added in 1.1.0-alpha10
public ExerciseSessionRecord(
    @NonNull Instant startTime,
    ZoneOffset startZoneOffset,
    @NonNull Instant endTime,
    ZoneOffset endZoneOffset,
    int exerciseType,
    String title,
    String notes,
    @NonNull Metadata metadata,
    @NonNull List<@NonNull ExerciseSegment> segments,
    @NonNull List<@NonNull ExerciseLap> laps,
    ExerciseRoute exerciseRoute,
    String plannedExerciseSessionId
)

Public methods

equals

public boolean equals(Object other)

getEndTime

Added in 1.1.0-alpha10
public @NonNull Instant getEndTime()

End time of the record.

getEndZoneOffset

Added in 1.1.0-alpha10
public ZoneOffset getEndZoneOffset()

User experienced zone offset at 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.

getExerciseRouteResult

Added in 1.1.0-alpha10
public final @NonNull ExerciseRouteResult getExerciseRouteResult()

ExerciseRouteResult of the session. Location data points of ExerciseRoute should be within the parent session, and should be before the end time of the session.

getExerciseType

Added in 1.1.0-alpha10
public final int getExerciseType()

Type of exercise (e.g. walking, swimming). Required field.

getLaps

Added in 1.1.0-alpha10
public final @NonNull List<@NonNull ExerciseLapgetLaps()

ExerciseLaps of the session. Optional field. Time in laps should be within the parent session, and should not overlap with each other.

getMetadata

Added in 1.1.0-alpha10
public @NonNull Metadata getMetadata()

Set of common metadata associated with the written record.

getNotes

Added in 1.1.0-alpha10
public final String getNotes()

Additional notes for the session. Optional field.

getPlannedExerciseSessionId

Added in 1.1.0-alpha10
public final String getPlannedExerciseSessionId()

getSegments

Added in 1.1.0-alpha10
public final @NonNull List<@NonNull ExerciseSegmentgetSegments()

ExerciseSegments of the session. Optional field. Time in segments should be within the parent session, and should not overlap with each other.

getStartTime

Added in 1.1.0-alpha10
public @NonNull Instant getStartTime()

Start time of the record.

getStartZoneOffset

Added in 1.1.0-alpha10
public ZoneOffset getStartZoneOffset()

User experienced zone offset at 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.

getTitle

Added in 1.1.0-alpha10
public final String getTitle()

Title of the session. Optional field.

hashCode

public int hashCode()

toString

public @NonNull String toString()