Skip to main content

Step 1: Create a Spike Connection

To set up the Spike SDK create SpikeConnectionV3 instance with your Spike application id, application user id and signature unique to each of your application users (more on generating signatures here):

Step 2: Ask User for Permissions

If you want to read data from Android Health Connect, you have to ensure the user gives your app permissions. First, you have to check if Health Connect is available on users’ phone:
where
If an update is required, you can use Spike helper to open Play Store for user to install Health Connect:
If Health Connect is installed, you can get permissions that are needed and a list of already provided permissions:
If you have missing permissions, you can ask Android to present the user with a modal asking user for permission to read the data. Example for Compose:
Please note that users might only grant partial permissions. In such cases, it’s up to you to decide whether your app can function effectively with limited access. The Spike SDK itself will still operate even without full permissions; however, it may result in no data being returned in certain scenarios. Conversely, if your app has been granted additional permissions beyond the minimum required for specific data types, we may enhance certain entries by incorporating data sourced from other types (e.g., identifying manually entered data).
You can now use StatisticsFilter(providers = listOf(Provider.HEALTH_CONNECT)) to specifically retrieve data from Health Connect. Alternatively, you can omit the providers parameter entirely and allow Spike to choose the most suitable data source based on your request.

Step 3: Get Data

The maximum permitted query date range is 90 days
There are four types of data you can retrieve from Spike:
  • Statistics are calculated values derived from records.
  • Activities are data about user’s activities or workouts.
  • Sleep is data about user’s sleep.
  • Records consist of the raw data points collected from user devices or applications.

Statistics

Get daily statistics for steps and total distance from health Connect:
Reference:

Records

Get all records we have from Garmin provider:
Reference: