Check for feature availability

When new features are added to Health Connect, users may not always update their version of Health Connect. The Feature Availability API is a way to check if a feature in Health Connect is available on your user's device and decide what action to take.

Get started

The Feature Availability API shares the same dependency as the Health Connect SDK. To get started, verify that at least version 1.1.0-alpha08 is in your build.gradle file:

dependencies {
  implementation("androidx.health.connect:connect-client:1.1.0-alpha08")
}

Perform the check

The main function to check for feature availability is getFeatureStatus(). This returns integer constants FEATURE_STATUS_AVAILABLE or FEATURE_STATUS_UNAVAILABLE:

To determine whether a user's device supports Read Health Data in Background on Health Connect, check the availability of FEATURE_READ_HEALTH_DATA_IN_BACKGROUND on the client:

if (healthConnectClient
     .features
     .getFeatureStatus(
       HealthConnectFeatures.FEATURE_READ_HEALTH_DATA_IN_BACKGROUND
     ) == HealthConnectFeatures.FEATURE_STATUS_AVAILABLE) {

  // Feature is available
} else {
  // Feature isn't available
}

For a list of all available feature flags, see the HealthConnectFeatures reference page.

Handle lack of feature availability

If a feature isn't available on a user's device, an update may enable it. You may consider directing the user to update Health Connect if they don't have the latest supported version on their device. However, users using the APK (on Android 13 and lower) can't use the system module features that are only available on devices running Android 14 or higher.

For extended device types, if FEATURE_EXTENDED_DEVICE_TYPES isn't available on the user's device, those values are treated as Device.TYPE_UNKNOWN. Provide a sensible fallback in your write and UI logic.