Programming Guide
Samsung Health SDK for Android helps Samsung Health's partners to share health data safely and to create useful health applications. Samsung Health has a health data store where its data can be shared with other partner apps after the user's consent. It supports Android devices with Marshmallow 6.0 including non-Samsung devices.
Refer to the following table terms for Samsung Health SDK for Android.
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 SDK for Android. An app that uses the SDK works with Samsung Health. |
Samsung Health | An application that helps monitor the user's activities and helps the users to have a healthier life through monitoring walking steps, exercise, heart rate, and etc. It can be downloaded from the app market like Google Play or Galaxy Apps. The term is italicized to be easily distinguished. |
Health Data Framework
The health data framework of Samsung Health SDK for Android has the following features:
-
Health Data Store
- Handling the connection to Samsung Health
- Inserting, reading, updating, or deleting health data
- Storing 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 its data and to have a seamless health service to the user. The following figure shows the health data framework's architecture.
Health Data Framework
The health data framework is included in Samsung Health. Applications can access the user's data that are stored in Samsung Health through the SDK. It keeps the user's health data safely. Health data from various source devices having pedometer, accelerator, or heart rate sensors are inserted to the health data framework with the unified data unit. The data can be read by the SDK. Updating or deleting data is available if the app inserted the data.
The figure above shows the class and interface relationships in Health Data. Detailed descriptions for each class and interface are in the API Reference.
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 the data. HealthDataResolver is a central class to handle the 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 SDK for Android provides. See Health Data Type for more information. Especially HealthConstants.Common, the base interface of predefined data types, 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
The health data can be accessed with the user's consent. The following figure shows the relationship between classes and interfaces related to HealthPermissionManager. It requests permissions to the user with HealthPermissionManager.PermissionKey
to read or write for the specific health data type. The permission result can be received synchronous or asynchronously. See Privacy for more information.
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 for details.
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 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 defined 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. |
HealthDataStore | This class handles the connection to the data store in the device. |
HealthDataUnit | This class provides unified units for the health data store. |
HealthDataUtil | This class provides useful utility APIs. |
HealthDevice | This class contains detailed device information that provides health data. |
HealthDeviceManager | 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. |