Class WorkoutConfiguration

java.lang.Object
com.codename1.health.workout.WorkoutConfiguration

public final class WorkoutConfiguration extends Object
Describes a workout about to be started.
  • Constructor Details

    • WorkoutConfiguration

      public WorkoutConfiguration()
  • Method Details

    • setActivityType

      public WorkoutConfiguration setActivityType(WorkoutActivityType activityType)
      The kind of exercise. Defaults to WorkoutActivityType.OTHER.
    • getActivityType

      public WorkoutActivityType getActivityType()
      The configured activity.
    • setLocationType

      public WorkoutConfiguration setLocationType(WorkoutLocationType locationType)
      Indoors or outdoors -- see WorkoutLocationType, which affects whether GPS is used.
    • getLocationType

      public WorkoutLocationType getLocationType()
      The configured location type.
    • setKeepAliveInBackground

      public WorkoutConfiguration setKeepAliveInBackground(boolean keepAliveInBackground)

      Asks the operating system to keep the app running while the workout records.

      On watchOS and iOS 26 the workout session itself holds the process alive and this needs nothing further. On Android it requires a foreground service, so the app must set the android.health.foregroundService build hint -- without it, starting such a session fails configuration validation rather than being silently killed mid-run.

    • isKeepAliveInBackground

      public boolean isKeepAliveInBackground()
      true when background recording was requested.
    • addCollectedType

      public WorkoutConfiguration addCollectedType(HealthDataType type)
      Asks the platform to collect this type automatically during the workout. Honoured only where WorkoutManager.isSensorCollectionSupported() is true; elsewhere you must feed samples in yourself with WorkoutSession.addSamples(java.util.List).
    • getCollectedTypes

      public List<HealthDataType> getCollectedTypes()
      The types requested for automatic collection.
    • setTitle

      public WorkoutConfiguration setTitle(String title)
      A user-visible title for the workout.
    • getTitle

      public String getTitle()
      The configured title, or null.