Requirements
- Samsung Health Data SDK runs on devices with Android 10 (API level 29) or above. It is available on all Samsung smartphones and non-Samsung Android smartphones.
- Samsung Health Data SDK works with Samsung Health. Samsung Health version 6.30.2 or higher is required.
- Samsung Health Data SDK supports Java 17 or higher version.
- The emulator is not supported.
- Data obtained using Samsung Health Data SDK is for fitness and wellness information only. It is not for the diagnosis or treatment of any medical condition.
Step 1: Create Spike connection
If you already set up Health Connect integration in your app, you should skip this step and use the same SpikeSDK connection object.
SpikeConnectionV3
instance with your Spike application id, application user id and signature unique to each of your apllication users (more on generating signatures here):
Step 2: Ask user for permissions
If you want to read data from Samsung Health, you have to ensure user gives your app permissions. First, you have to check if Samsung Health is available on users phone using checkSamsungHealthDataAvailability method: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 SpikeSDK itself will still operate even without full permissions; however, it may result in no data being returned in certain scenarios.
You can now use
StatisticsFilter(providers = listOf(Provider.SAMSUNG_HEALTH_DATA))
to specifically retrieve data from Samsung Health. 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
There are 4 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 Samsung Health using getStatistics method:Records
Get all records we have from Samsung Health using getRecords method:Background delivery
Samsung Health data can be delivered in background the same way as Apple HealthKit or Android Health Connect. If you want to use background delivery to get Samsung Health data, you have to enable Samsung Health Data integration first:Additional information
ThespikeConnection.getUserInfo()
call will only show that Apple HealthKit, Android Health Connect, or Samsung Health Data is enabled after you have successfully retrieved data at least once using functions like getStatistics()
, getRecords()
, or similar data retrieval methods.
Developer mode for testing
In order to test Samsung Health Data integration on your phone you have to enable developer mode in Samsung Health app:- Tap the ‘⋮’ button of Samsung Health in the top-right.
- Select Settings > About Samsung Health.
- Tap the version line region quickly 10 times or more. If you are successful, the Developer mode (Samsung Health Data SDK) button is displayed.
- Select Developer mode (Samsung Health Data SDK) .
- Agree with Notice of usage of the Developer mode.
- For reading data from Samsung Health with Samsung Health Data SDK, turn Developer Mode for Data Read on.
The Samsung Health developer mode is ONLY intended for testing or debugging your app. It is NOT for app users. Do not provide a developer mode guide to app users.