FAQ

  • 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 Marshmallow or above. It consists a big ecosystem including various health apps and connected accessory 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 Marshmallow 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 Samsung Health Android SDK’s Health Data provides a solution to check it through HealthConnectionErrorResult.hasResolution(). If the app meets the following cases, it means 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();
                data.setSourceDevice(myDevice.getUuid());
        
                // 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() 
                    .setDataType(HealthConstants.Sleep.HEALTH_DATA_TYPE)
                    .build();
                // Do something
            }
        }
  • A

    Handling all use cases for the phone and linked multi-accessory devices is not easy with it because the phone and accessory device like Galaxy Watch can provide step count data at the same time or not depending on how many devices are carried by the user.

    Samsung Health SDK provides the following data types for steps:

     -  Daily step count trend

     -  HealthConstants.StepCount

    Daily step count trend is used to generally to read the user’s daily steps.

    Especially, its source type "-2" provides the day’s total steps simply without excluding duplicated steps when one more source devices provide steps at the same time.

    See "com.samsung.shealth.step_daily_trend"

    HealthConstants.StepCount is useful:

     -  Getting each source device’s step count

     -  Getting real-time step count of the phone that Samsung Health is installed.

  • 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.

        @Override
            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.
        }