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.1 |
6.28 or above |
1.5.0 |
6.12 or above |
1.4.0 |
6.2 or above |
1.3.0 |
5.11 or above |
1.2.0 |
5.10 or above |
1.0.0 |
4.0 or above |
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.
- Connect to the health data store.
See
HealthDataStore.connectService()
.
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();
}
- If it fails, check
HealthConnectionErrorResult.onConnectionFailed()
.
private final HealthDataStore.ConnectionListener mConnectionListener = new HealthDataStore.ConnectionListener() {
// ...
@Override
public void onConnectionFailed(HealthConnectionErrorResult error) {
// ...
}
- 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.
@Override
public void onConnectionFailed(HealthConnectionErrorResult error) {
if (error.getErrorCode() == HealthConnectionErrorResult.OLD_VERSION_PLATFORM) {
// Show a message to the user to update Samsung Health
}
}
- Check a resolution for the error with
HealthConnectionErrorResult.hasResolution()
.
If it gives true, resolve the error with
HealthConnectionErrorResult.resolve()
.
if (error.hasResolution()) {
// If there is a solution, resolve it
error.resolve(MainActivity.this);
}
- The Samsung Health platform leads to upgrade Samsung Health on the app market.
See its example: