• A

    Samsung Health app is a most popular health app and has more than 50 million of monthly active users. It works not only on Samsung smartphones but also non-Samsung phones if the device supports Android KitKat or above. It consist a big ecosystem including various health apps and connected devices.

    Samsung Health Android SDK enables your app to manage the user’s health data with the unified interface by connecting to Samsung Health app. You can have more enhanced chances with a partnership of Samsung Health.

  • A

    Even though Samsung Health is installed in Android smartphones with KitKat or above including Samsung and non-Samsung smartphones, some phones cannot support Samsung Health. Its check code needs to be added to prevent a relevant situation.

    The Health Data 1.1.0 or above has a solution to check for it through HealthConnectionErrorResult.hasResolution(). If the app meets both following error cases, it includes the meaning that the device is not available for Samsung Health.

      • HealthDataStore.connectService() gives a failure event.
      • HealthConnectionErrorResult.hasResolution() returns false.

    See an example for failure exception handling.

  • A

    All data type interfaces extend the HealthConstants.Common interface basically. Some data types extend HealthConstants.DiscreteMeasurement and others extend HealthConstants.SessionMeasurement depending on whether the end measured time exists.

    For example, HealthConstants.Sleep extends:

    • HealthConstants.Common
    • HealthConstants.SessionMeasurement

    You can set HealthConstants.Sleep’s following properties including its own ones.

    • HealthConstants.Common.DEVICE_UUID
    • HealthConstants.SessionMeasurement.START_TIME
    • HealthConstants.SessionMeasurement.END_TIME

    See the "Properties" description of each data type interface in API Reference for more information.

    Sleep data can be set as the example shown below.

    public class HealthDataExample {
        // The state of connection
        private HealthDataStore mStore;
        private void insertSleepData(long start, long end, long offset) {
            HealthDevice myDevice = new HealthDeviceManager(mStore).getLocalDevice();
            HealthData data = new HealthData();
            // Fills all mandatory properties out
            data.putLong(HealthConstants.Sleep.START_TIME, start);
    data.putFloat(HealthConstants.Sleep.END_TIME, end);
            data.putLong(HealthConstants.Sleep.TIME_OFFSET, offset);
    HealthDataResolver resolver = new HealthDataResolver(mStore, null);
            HealthDataResolver.InsertRequest insRequest = new HealthDataResolver.InsertRequest.Builder()
            // Do something
  • A

    You can get each source device’s step count data through HealthConstants.StepCount. But handling all use cases for the phone device and linked multi-accessory is not easy with it because the phone device and accessory can provides step count data at the same time or not depending on how many devices are carried by the user.

    HealthConstants.StepCount is useful to get the user’s real-time step count in the phone that Samsung Health is installed.


    Samsung Health provides a custom data type for the user’s daily step count summary data with:

    A summarized step count data is created at about 00:00:00 UTC every day with step_daily_trend and updated every minute until the next day comes.

    "source_type" of "com.samsung.shealth.step_daily_trend" " is a very useful property to get the user’s valid step count easily under the multi-accessory environment. It indicates the kind of data sources like the wearable device, the activity tracker, or all. It’s different with the data’s source device from HealthConstant.Common.DEVICE_UUID.

    See its available values in API Reference. The most used value is -2. It gets the user’s valid step count without duplicated steps in multi-devices including partner apps, local device, wearable accessories, and activity trackers. You can query it as the following example.

    	// The state of connection
    private HealthDataStore mStore;
    public void readDailyStepCountData() {
        // Suppose that the required permission has been acquired already
        // Create a filter for all source types
        Filter filter = Filter.eq("source_type", -2);
        ReadRequest request = new ReadRequest.Builder()
            // Set the StepCount data type to aggregate data
            // Set the source type with a filter
            // Set the sort order
            .setSort("day_time", HealthDataResolver.SortOrder.DESC)
            // Build
         HealthDataResolver resolver = new HealthDataResolver(mStore, null);
         try {
         } catch (Exception e) {
             Log.e(MainActivity.APP_TAG, e.getClass().getName() + " - " + e.getMessage());
    private final HealthResultHolder.ResultListener
                mStepCountListener = new HealthResultHolder.ResultListener
                () { @Override public void onResult(ReadResult result) { Cursor c = null; try { c = result.getResultCursor(); if (c != null) { while(c.moveToNext()) { long dayTime = c.getLong(c.getColumnIndex("day_time")); int stepCount = c.getInt(c.getColumnIndex("count")); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd"); Log.d(APP_TAG, dateFormat.format(dayTime)); Log.d(APP_TAG, "Step Count: " + stepCount); } } else { Log.d(APP_TAG, "The cursor is null."); } } catch(Exception e) { Log.e(APP_TAG, e.getClass().getName() + " - " + e.getMessage()); } finally { if (c != null) { c.close(); } } } };
  • A

    If new data is inserted to the health data store, CREATED_TIME, UPDATED_TIME of HealthConstants.Common are assigned by the system automatically. So you don’t need to set them separately. Data’s START_TIME or END_TIME indicates its UTC measurement time in milliseconds. Be careful not to set START_TIME or END_TIME as the device’s current local time.

    TIME_OFFSET is indicated by the time zone and daylight saving time in milliseconds and it helps in showing the health data’s measured time properly in the device. The following example shows getting the current device’s TIME_OFFSET.

    import java.util.TimeZone;
     public class HeathDataExample {
         long getTimeOffset(long intakeTime) {
             return TimeZone.getDefault().getOffset(intakeTime);
  • A

    TrackerTileManager.post() should be called in the implemented TrackerEventListener.onSubscribed() to post your tracker tile.

    	public void onSubscribed(Context context, String trackerId) {
    	    // User changed the subscription state of your tracker to subscribe.
    	    // Post your tracker tile here to show it on the Samsung Health's main screen
    	    // by calling TrackerTileManager.post().
    	    // Use TRACKER_TILE_TYPE_1 if there is no data yet.