Enum HealthAuthorizationStatus

java.lang.Object
java.lang.Enum<HealthAuthorizationStatus>
com.codename1.health.HealthAuthorizationStatus
All Implemented Interfaces:
Comparable<HealthAuthorizationStatus>

public enum HealthAuthorizationStatus extends Enum<HealthAuthorizationStatus>

The app's authorization for one data type and one direction.

The asymmetry you must handle

Write authorization is truthfully reportable on both platforms. Read authorization is not. HealthKit deliberately refuses to disclose it, because telling an app "the user denied you access to pregnancy data" leaks the very thing the user was hiding. So HealthStore.getReadAuthorizationStatus(HealthDataType) returns UNKNOWN on iOS regardless of what the user actually chose, and any code that branches on it must handle that value.

  • Enum Constant Details

    • NOT_DETERMINED

      public static final HealthAuthorizationStatus NOT_DETERMINED
      The user has not been asked yet.
    • AUTHORIZED

      public static final HealthAuthorizationStatus AUTHORIZED
      The app holds the access.
    • DENIED

      public static final HealthAuthorizationStatus DENIED
      The user explicitly refused the access.
    • RESTRICTED

      public static final HealthAuthorizationStatus RESTRICTED
      Access is blocked by something outside the user's control at this moment -- a device management policy, or a data type the platform does not permit this app to touch.
    • UNKNOWN

      public static final HealthAuthorizationStatus UNKNOWN

      The platform will not say. Returned for read access on iOS in every case, by design; it means neither "granted" nor "denied" and must not be rendered to the user as either.

      The only honest way to find out whether reads work is to run a query -- see HealthStore.hasAnyData(HealthDataType,HealthTimeRange).

    • NOT_SUPPORTED

      public static final HealthAuthorizationStatus NOT_SUPPORTED
      This platform has no health store, so the question does not apply.
  • Method Details

    • values

      public static HealthAuthorizationStatus[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static HealthAuthorizationStatus valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null