Programming Guide Jan 11, 2018

Samsung Health Android SDK helps Samsung Health' s partners to share health data safely and to create useful health applications. The health data store’s integrated health data in Samsung Health can be shared with other Samsung Health' s partner apps after the user’s consent. Samsung Health supports Android devices with KitKat 4.4 including non-Samsung devices.

Figure: Samsung Health integration with SDK

Refer to the following table for Samsung Health Android SDK glossary.

Term Description
Health Data framework It provides useful features to handle the user’s health data. It is included in Samsung Health and its interface is provided with Samsung Health Android SDK. An app that uses the SDK works with Samsung Health.
Samsung Health An application that helps monitor the user’s activities and helps the user makes a healthier life with monitoring walking steps, exercise, heart rate, and etc. It can be downloaded from the app market like Google Play or Galaxy Apps.
It’s marked with italic to distinguish easily.
Table: Glossary

The SDK provides the following packages.

  • Health Data

  • Health Service

This document contains descriptions for the SDK’s Health Data. See the Health Service’s documents if you want to launch one of Samsung Health trackers or post your app’s tracker on Samsung Health.

Health Data Framework

The health data framework of Samsung Health Android SDK provides the following features:

  • Health Data Store

    • Handling the connection to Samsung Health.
    • Inserting, reading, updating, deleting health data.
    • Based on unified units. See API Reference’s descriptions for each data type.
  • Health Data Type

    • Platform-defined and custom data type.
  • Privacy

    • Granting permission based on the user’s consent to read or write the specific data type.

Architecture

The SDK’s health data framework is designed to provide safe access of health data and a seamless health service to the user. The following figure is the health data framework’s architecture.

Figure: Health data framework architecture

The detailed description is presented below.

Health Data Framework

The health data framework is included in Samsung Health. Applications can access the health data store’s data of Samsung Health with the SDK. It keeps the user’s health data safely. Health data from various source devices that have pedometer, accelerator, or heart rate sensors are inserted to the health data framework with the unified data unit. The data in health data framework can be read with the SDK. Updating or deleting data is available if the app inserted the data.

Partner Apps

An app that uses Samsung Health Android SDK works with Samsung Health on its developer mode at first. Setting Samsung Health to the developer mode can be inconvenient to the app’s users. Otherwise, the developer mode can give a simple solution if your app is on test or is opened to only internal small users.

To skip the dev mode, get an approval as Samsung Health’s partner. The partner app request is available in the developer site. Data sync with Samsung Health should be work well before the partner app request. The SDK’s DataViewer tool and app checklist can help the app test efficiently.

Figure: Class diagram for HealthDataStore

The figure shows the class and interface relationships in Health Data. Detailed descriptions for each class and interface are in the API Reference.

HealthDataService.initialize()

It initializes the health data service. APIs of the com.samsung.android.sdk.healthdata works properly after calling it without an exception.

HealthDataStore

It handles the connection to the data storage of the device. It receives its connection result with HealthDataStore.ConnectionListener. Most requests require the connection to the health data store.

HealthDataResolver

The health data framework provides classes and interfaces to insert, read, update, or delete health data. HealthDataResolver is a central class to handle health data. It sends a data request with related request interfaces.

The query result can be received immediately with HealthDataHolder.BaseResult, HealthDataResolver.ReadResult or HealthDataResolver.AggregateResult. Or it can be received asynchronously with HealthResultHolder.ResultListener. See Health Data Store for more information.

Application developers can use platform-defined data types that Samsung Health Android SDK provides. See Health Data Type for more information. Especially HealthConstants.Common contains the following mandatory properties for health data.

  • Unique ID of health data.

  • Created and updated time of health data.

  • Application package name.

  • Device that provides health data.

Figure: Class diagrams of SessionMeasurement data types

HealthConstants.Common is the base class of the predefined data types.

Figure: Class diagrams of DiscreteMeasurement

The user’s health data can be accessed with the user’s consent. The following figure shows relationship between classes and interfaces related to HealthPermissionManager. It requests permissions with HealthPermissionManager.PermissionKey that contains the required permission to read or write for the specific health data type. The permission result can be received synchronous or asynchronously. See Privacy for more information.

Figure: Class diagram related to HealthPermissionManager

The SDK’s Health Data library provides the following package:

  • com.samsung.android.sdk.healthdata

Main interfaces and classes in the library are described in the following table. See the API reference on details.

com.samsung.android.sdk.healthdata
Interface / Class Description
HealthConnectionErrorResult This class handles errors for connection failure to the health data store.
HealthConstants This class defines constants of health data and contains interfaces for various kinds of health data such as the step count or exercise.
HealthData This class is an object for a health data type, e.g., the blood pressure or weight. Quantitative and qualitative values can be specified for the specific health data type based on its data structure definition. It is used to manage health data with HealthDataResolver.
HealthDataObserver This class defines an observer to handle health data changes.
HealthDataResolver This class accesses health data to insert, read, update, and delete with the filter and aggregate functions.
HealthDataService This class initializes the health data service.
HealthDataStore This class handles the connection to the data store in the device.
HealthDataUnit This class provides unified units for the health data store.
HealthDataUnit This class provides useful utility APIs.
HealthDevice This class contains detailed device information that provides health data.
HeatlthDeviceManager This class manages devices related health data.
HealthPermissionManager This class requests permission to read or write health data for the specific health data type.
HealthResultHolder This interface represents the result of invoking method.
HealthUserProfile This class provides the user information.
Table: Interfaces and classes of com.samsung.android.sdk.healthdata