Class WorkoutSample
java.lang.Object
com.codename1.health.HealthSample
com.codename1.health.SessionSample
com.codename1.health.WorkoutSample
A completed workout: what kind, how long, and the totals the platform computed for it.
Totals are nullable on purpose. A workout recorded without a heart-rate
sensor has no energy total, and reporting that as zero would put a
false 0 kcal into every summary. null means "not measured"; zero
means "measured, and it was zero".
-
Method Summary
Modifier and TypeMethodDescriptionstatic WorkoutSamplecreate(WorkoutActivityType activityType, long startMillis, long endMillis) Creates a workout spanning[startMillis, endMillis].longTime actually exercising, excluding pauses.The activity, mapped onto this API's shared vocabulary.intThe raw platform activity constant -- anHKWorkoutActivityTypeon iOS or anExerciseSessionRecordexercise type on Android -- or-1when unknown.Distance covered, or null when not measured.Energy burned across the workout, or null when not measured.voidsetActiveDurationMillis(long activeDurationMillis) Sets the paused-time-excluded duration.voidsetPlatformCode(int platformCode) Records the raw platform activity constant.voidsetTotalDistance(HealthQuantity totalDistance) Sets the distance total.voidsetTotalEnergy(HealthQuantity totalEnergy) Sets the energy total.toString()Returns a string representation of the object.Methods inherited from class SessionSample
getNotes, getTitle, setNotes, setTitleMethods inherited from class HealthSample
equals, getDurationMillis, getEndMillis, getId, getMetadata, getRecordingMethod, getSource, getStartMillis, getType, hashCode, isInstantaneous, putMetadata, setId, setRecordingMethod, setSource
-
Method Details
-
create
public static WorkoutSample create(WorkoutActivityType activityType, long startMillis, long endMillis) Creates a workout spanning[startMillis, endMillis]. -
getActivityType
The activity, mapped onto this API's shared vocabulary. SeegetPlatformCode()when you need exactly what the platform said. -
getPlatformCode
public int getPlatformCode()The raw platform activity constant -- an
HKWorkoutActivityTypeon iOS or anExerciseSessionRecordexercise type on Android -- or-1when unknown.This is the fidelity escape hatch for the deliberately partial
WorkoutActivityTypevocabulary. It is platform-specific by definition: the same integer means different things on the two platforms, so branch ongetActivityType()first and only reach for this when you must. -
setPlatformCode
public void setPlatformCode(int platformCode) Records the raw platform activity constant. Called by ports. -
getTotalEnergy
Energy burned across the workout, or null when not measured. -
setTotalEnergy
Sets the energy total. -
getTotalDistance
Distance covered, or null when not measured. -
setTotalDistance
Sets the distance total. -
getActiveDurationMillis
public long getActiveDurationMillis()Time actually exercising, excluding pauses. Falls back to the wall duration when the platform did not report it separately. -
setActiveDurationMillis
public void setActiveDurationMillis(long activeDurationMillis) Sets the paused-time-excluded duration. -
toString
Description copied from class:ObjectReturns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + '@' + Integer.toHexString(hashCode())- Overrides:
toStringin classHealthSample
-