ExerciseSessionRecord


class ExerciseSessionRecord : 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

const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int

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

const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int
const Int

Public companion properties

AggregateMetric<Duration>

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

Public constructors

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

Public functions

open operator Boolean
equals(other: Any?)
open Int
open String

Public properties

open Instant

End time of the record.

open ZoneOffset?

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

ExerciseRouteResult

ExerciseRouteResult of the session.

Int

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

List<ExerciseLap>

ExerciseLaps of the session.

open Metadata

Set of common metadata associated with the written record.

String?

Additional notes for the session.

String?
List<ExerciseSegment>

ExerciseSegments of the session.

open Instant

Start time of the record.

open ZoneOffset?

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

String?

Title of the session.

Constants

EXERCISE_TYPE_BADMINTON

const val EXERCISE_TYPE_BADMINTON = 2: Int

EXERCISE_TYPE_BASEBALL

const val EXERCISE_TYPE_BASEBALL = 4: Int

EXERCISE_TYPE_BASKETBALL

const val EXERCISE_TYPE_BASKETBALL = 5: Int

EXERCISE_TYPE_BIKING

const val EXERCISE_TYPE_BIKING = 8: Int

EXERCISE_TYPE_BIKING_STATIONARY

const val EXERCISE_TYPE_BIKING_STATIONARY = 9: Int

EXERCISE_TYPE_BOOT_CAMP

const val EXERCISE_TYPE_BOOT_CAMP = 10: Int

EXERCISE_TYPE_BOXING

const val EXERCISE_TYPE_BOXING = 11: Int

EXERCISE_TYPE_CALISTHENICS

const val EXERCISE_TYPE_CALISTHENICS = 13: Int

EXERCISE_TYPE_CRICKET

const val EXERCISE_TYPE_CRICKET = 14: Int

EXERCISE_TYPE_DANCING

const val EXERCISE_TYPE_DANCING = 16: Int

EXERCISE_TYPE_ELLIPTICAL

const val EXERCISE_TYPE_ELLIPTICAL = 25: Int

EXERCISE_TYPE_EXERCISE_CLASS

const val EXERCISE_TYPE_EXERCISE_CLASS = 26: Int

EXERCISE_TYPE_FENCING

const val EXERCISE_TYPE_FENCING = 27: Int

EXERCISE_TYPE_FOOTBALL_AMERICAN

const val EXERCISE_TYPE_FOOTBALL_AMERICAN = 28: Int

EXERCISE_TYPE_FOOTBALL_AUSTRALIAN

const val EXERCISE_TYPE_FOOTBALL_AUSTRALIAN = 29: Int

EXERCISE_TYPE_FRISBEE_DISC

const val EXERCISE_TYPE_FRISBEE_DISC = 31: Int

EXERCISE_TYPE_GOLF

const val EXERCISE_TYPE_GOLF = 32: Int

EXERCISE_TYPE_GUIDED_BREATHING

const val EXERCISE_TYPE_GUIDED_BREATHING = 33: Int

EXERCISE_TYPE_GYMNASTICS

const val EXERCISE_TYPE_GYMNASTICS = 34: Int

EXERCISE_TYPE_HANDBALL

const val EXERCISE_TYPE_HANDBALL = 35: Int

EXERCISE_TYPE_HIGH_INTENSITY_INTERVAL_TRAINING

const val EXERCISE_TYPE_HIGH_INTENSITY_INTERVAL_TRAINING = 36: Int

EXERCISE_TYPE_HIKING

const val EXERCISE_TYPE_HIKING = 37: Int

EXERCISE_TYPE_ICE_HOCKEY

const val EXERCISE_TYPE_ICE_HOCKEY = 38: Int

EXERCISE_TYPE_ICE_SKATING

const val EXERCISE_TYPE_ICE_SKATING = 39: Int

EXERCISE_TYPE_MARTIAL_ARTS

const val EXERCISE_TYPE_MARTIAL_ARTS = 44: Int

EXERCISE_TYPE_OTHER_WORKOUT

const val EXERCISE_TYPE_OTHER_WORKOUT = 0: Int

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

const val EXERCISE_TYPE_PADDLING = 46: Int

EXERCISE_TYPE_PARAGLIDING

const val EXERCISE_TYPE_PARAGLIDING = 47: Int

EXERCISE_TYPE_PILATES

const val EXERCISE_TYPE_PILATES = 48: Int

EXERCISE_TYPE_RACQUETBALL

const val EXERCISE_TYPE_RACQUETBALL = 50: Int

EXERCISE_TYPE_ROCK_CLIMBING

const val EXERCISE_TYPE_ROCK_CLIMBING = 51: Int

EXERCISE_TYPE_ROLLER_HOCKEY

const val EXERCISE_TYPE_ROLLER_HOCKEY = 52: Int

EXERCISE_TYPE_ROWING

const val EXERCISE_TYPE_ROWING = 53: Int

EXERCISE_TYPE_ROWING_MACHINE

const val EXERCISE_TYPE_ROWING_MACHINE = 54: Int

EXERCISE_TYPE_RUGBY

const val EXERCISE_TYPE_RUGBY = 55: Int

EXERCISE_TYPE_RUNNING

const val EXERCISE_TYPE_RUNNING = 56: Int

EXERCISE_TYPE_RUNNING_TREADMILL

const val EXERCISE_TYPE_RUNNING_TREADMILL = 57: Int

EXERCISE_TYPE_SAILING

const val EXERCISE_TYPE_SAILING = 58: Int

EXERCISE_TYPE_SCUBA_DIVING

const val EXERCISE_TYPE_SCUBA_DIVING = 59: Int

EXERCISE_TYPE_SKATING

const val EXERCISE_TYPE_SKATING = 60: Int

EXERCISE_TYPE_SKIING

const val EXERCISE_TYPE_SKIING = 61: Int

EXERCISE_TYPE_SNOWBOARDING

const val EXERCISE_TYPE_SNOWBOARDING = 62: Int

EXERCISE_TYPE_SNOWSHOEING

const val EXERCISE_TYPE_SNOWSHOEING = 63: Int

EXERCISE_TYPE_SOCCER

const val EXERCISE_TYPE_SOCCER = 64: Int

EXERCISE_TYPE_SOFTBALL

const val EXERCISE_TYPE_SOFTBALL = 65: Int

EXERCISE_TYPE_SQUASH

const val EXERCISE_TYPE_SQUASH = 66: Int

EXERCISE_TYPE_STAIR_CLIMBING

const val EXERCISE_TYPE_STAIR_CLIMBING = 68: Int

EXERCISE_TYPE_STAIR_CLIMBING_MACHINE

const val EXERCISE_TYPE_STAIR_CLIMBING_MACHINE = 69: Int

EXERCISE_TYPE_STRENGTH_TRAINING

const val EXERCISE_TYPE_STRENGTH_TRAINING = 70: Int

EXERCISE_TYPE_STRETCHING

const val EXERCISE_TYPE_STRETCHING = 71: Int

EXERCISE_TYPE_SURFING

const val EXERCISE_TYPE_SURFING = 72: Int

EXERCISE_TYPE_SWIMMING_OPEN_WATER

const val EXERCISE_TYPE_SWIMMING_OPEN_WATER = 73: Int

EXERCISE_TYPE_SWIMMING_POOL

const val EXERCISE_TYPE_SWIMMING_POOL = 74: Int

EXERCISE_TYPE_TABLE_TENNIS

const val EXERCISE_TYPE_TABLE_TENNIS = 75: Int

EXERCISE_TYPE_TENNIS

const val EXERCISE_TYPE_TENNIS = 76: Int

EXERCISE_TYPE_VOLLEYBALL

const val EXERCISE_TYPE_VOLLEYBALL = 78: Int

EXERCISE_TYPE_WALKING

const val EXERCISE_TYPE_WALKING = 79: Int

EXERCISE_TYPE_WATER_POLO

const val EXERCISE_TYPE_WATER_POLO = 80: Int

EXERCISE_TYPE_WEIGHTLIFTING

const val EXERCISE_TYPE_WEIGHTLIFTING = 81: Int

EXERCISE_TYPE_WHEELCHAIR

const val EXERCISE_TYPE_WHEELCHAIR = 82: Int

EXERCISE_TYPE_YOGA

const val EXERCISE_TYPE_YOGA = 83: Int

Public companion properties

EXERCISE_DURATION_TOTAL

val EXERCISE_DURATION_TOTALAggregateMetric<Duration>

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

Public constructors

ExerciseSessionRecord

Added in 1.1.0-alpha10
ExerciseSessionRecord(
    startTime: Instant,
    startZoneOffset: ZoneOffset?,
    endTime: Instant,
    endZoneOffset: ZoneOffset?,
    exerciseType: Int,
    title: String? = null,
    notes: String? = null,
    metadata: Metadata = Metadata.EMPTY,
    segments: List<ExerciseSegment> = emptyList(),
    laps: List<ExerciseLap> = emptyList(),
    exerciseRoute: ExerciseRoute? = null,
    plannedExerciseSessionId: String? = null
)

Public functions

equals

open operator fun equals(other: Any?): Boolean

hashCode

open fun hashCode(): Int

toString

open fun toString(): String

Public properties

endTime

Added in 1.1.0-alpha10
open val endTimeInstant

End time of the record.

endZoneOffset

Added in 1.1.0-alpha10
open val endZoneOffsetZoneOffset?

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.

exerciseRouteResult

Added in 1.1.0-alpha10
val exerciseRouteResultExerciseRouteResult

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.

exerciseType

Added in 1.1.0-alpha10
val exerciseTypeInt

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

laps

Added in 1.1.0-alpha10
val lapsList<ExerciseLap>

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

metadata

Added in 1.1.0-alpha10
open val metadataMetadata

Set of common metadata associated with the written record.

notes

Added in 1.1.0-alpha10
val notesString?

Additional notes for the session. Optional field.

plannedExerciseSessionId

Added in 1.1.0-alpha10
val plannedExerciseSessionIdString?

segments

Added in 1.1.0-alpha10
val segmentsList<ExerciseSegment>

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

startTime

Added in 1.1.0-alpha10
open val startTimeInstant

Start time of the record.

startZoneOffset

Added in 1.1.0-alpha10
open val startZoneOffsetZoneOffset?

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.

title

Added in 1.1.0-alpha10
val titleString?

Title of the session. Optional field.