Class WorkoutConfiguration
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAsks the platform to collect this type automatically during the workout.The configured activity.The types requested for automatic collection.The configured location type.getTitle()The configured title, or null.booleanAlwaysfalsein this release -- seesetKeepAliveInBackground(boolean).setActivityType(WorkoutActivityType activityType) The kind of exercise.setKeepAliveInBackground(boolean keepAliveInBackground) Asks the operating system to keep the app running while the workout records.setLocationType(WorkoutLocationType locationType) Indoors or outdoors -- seeWorkoutLocationType, which affects whether GPS is used.A user-visible title for the workout.
-
Constructor Details
-
WorkoutConfiguration
public WorkoutConfiguration()
-
-
Method Details
-
setActivityType
The kind of exercise. Defaults toWorkoutActivityType.OTHER. -
getActivityType
The configured activity. -
setLocationType
Indoors or outdoors -- seeWorkoutLocationType, which affects whether GPS is used. -
getLocationType
The configured location type. -
setKeepAliveInBackground
Asks the operating system to keep the app running while the workout records. Not available in this release -- passing
truethrows.Nothing honours it anywhere yet. Keeping the process alive needs either a live
HKWorkoutSession, whichWorkoutManager.isLiveSessionSupported()reports false for on every platform here, or an Android foreground service, which the build does not emit and for which no build hint exists. A setter that stored the request and let the workout be killed mid-run would be worse than one that refuses it: the app could not tell the difference until a user lost a workout.Until then, record with the app in the foreground, and write what you have collected rather than assuming the session will still be running when the user comes back.
Throws
IllegalArgumentException: ifkeepAliveInBackgroundistrue.
-
isKeepAliveInBackground
public boolean isKeepAliveInBackground()Alwaysfalsein this release -- seesetKeepAliveInBackground(boolean). -
addCollectedType
Asks the platform to collect this type automatically during the workout. Honoured only whereWorkoutManager.isSensorCollectionSupported()istrue; elsewhere you must feed samples in yourself withWorkoutSession.addSamples(java.util.List). -
getCollectedTypes
The types requested for automatic collection. -
setTitle
A user-visible title for the workout. -
getTitle
The configured title, or null.
-