Samsung Health Android SDK - Data API Reference 1.5.0

Health Data This document describes com.samsung.android.sdk.healthdata APIs in Samsung Health SDK for Android.

See: Description

Packages 
Package Description
com.samsung.android.sdk.healthdata
This package provides classes and interfaces for the health data framework in Samsung Health SDK for Android.

Health Data

This document describes com.samsung.android.sdk.healthdata APIs in Samsung Health SDK for Android.
The health data package contains classes and interfaces which enable you to create applications with the following functionalities.

Health Data Store

A partner app that uses Samsung Health SDK for Android can write its health data to Samsung Health or read Samsung Health's data through the health data store connection.
See Health Data Store for more information.

Health Data Type

The SDK provides useful predefined and custom data types.
See Health Data Types for more information.

Privacy

Data permission acquisition is required to access a specific data type.
See Permission Manager for more information.

For more information related to the development environment, fundamentals, features and sample descriptions, see Programming Guide.

Compatible version of Samsung Health

Samsung Health SDK for Android works with Samsung Health.
The SDK's data library works properly with the specific Samsung Health version.

SDK's Heath Data library version Samsung Health compatible version
1.5.0 6.12 or above
1.4.0 or above 6.2 or above
6.11 or below
1.3.0 5.11 or above
6.1 or below
1.2.0
1.2.1
5.10
1.0.0
1.1.0
4.0 or above
5.9 or below

E.g. if you create your app with the Health Data library 1.5.0, it requires to install Samsung Health 6.12 or above in the device.

If the SDK and Samsung Health's version is not matched, the SDK gives an error.

You can resolve the error simply and induce the users to update Samsung Health to the latest version.

Here is a guide to prevent the related error.

  1. Connect to the health data store. See HealthDataStore.connectService().
  2. private HealthDataStore mStore;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
    
        // Create a HealthDataStore instance and set its listener
        mStore = new HealthDataStore(this, mConnectionListener);
        // Request the connection to the health data store
        mStore.connectService();
    
    }
  3. If it fails, check HealthConnectionErrorResult.onConnectionFailed().
  4. private final HealthDataStore.ConnectionListener mConnectionListener = new HealthDataStore.ConnectionListener() {
    
        // ...
    
        @Override
        public void onConnectionFailed(HealthConnectionErrorResult error) {
            // ...
        }
  5. If the error is OLD_VERSION_PLATFORM, it means that Samsung Health needs to be updated to the latest version.
    Show a proper message to the user.
  6.     @Override
        public void onConnectionFailed(HealthConnectionErrorResult error) {
    
            if (error.getErrorCode() == HealthConnectionErrorResult.OLD_VERSION_PLATFORM) {
                // Show a message to the user to update Samsung Health
            }
        }
  7. Check a resolution for the error with HealthConnectionErrorResult.hasResolution().
    If it gives true, resolve the error with HealthConnectionErrorResult.resolve().
  8.         if (error.hasResolution()) {
                // If there is a solution, resolve it
                error.resolve(MainActivity.this);
            }
  9. The Samsung Health platform leads to upgrade Samsung Health on the app market.

See its example: