Step 1: Create a Spike Connection
To set up the Spike SDK createSpikeConnectionV3 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: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
- 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.
