• Learn
    • Code Lab
    • Foldables and Large Screens
    • One UI Beta
    • Samsung Developers Podcasts
  • Develop
    • Mobile/Wearable
    • Galaxy GameDev
    • Galaxy Themes
    • Galaxy Watch
    • Health
    • Samsung Blockchain
    • Samsung DeX
    • Samsung IAP
    • Samsung Internet
    • Samsung Pay
    • Samsung Wallet
    • View All
      • Galaxy AR Emoji
      • Galaxy Accessory
      • Galaxy Edge
      • Galaxy Z
      • Galaxy Performance
      • Galaxy FM Radio
      • Galaxy S Pen Remote
      • Galaxy Sensor Extension
      • PENUP
      • Samsung Automation
      • Samsung Neural
      • Samsung TEEGRIS
      • Samsung eSE SDK
    • Visual Display
    • Smart TV
    • Smart Hospitality Display
    • Smart Signage
    • Digital Appliance
    • Family Hub
    • Platform
    • Bixby
    • Knox
    • SmartThings
    • Tizen.NET
  • Design
    • Design System
    • One UI
    • One UI Watch
    • Smart TV
  • Distribute
    • Galaxy Store
    • TV Seller Office
    • Galaxy Store Games
    • Samsung Podcasts
  • Support
    • Developer Support
    • Remote Test Lab
    • Issues and Bugs Channel
    • Samsung Android USB Driver
    • Galaxy Emulator Skin
  • Connect
    • Blog
    • News
    • Forums
    • Events
    • Samsung Developer Conference
    • SDC22
    • SDC21
    • SDC19 and Previous Events
  • Sign In
Top Global Search Form
Recommendation
  • Blog
  • Code Lab
  • Foldable and Large Screen Optimization
  • Forums
  • Galaxy Emulator Skin
  • Galaxy GameDev
  • Health
  • Remote Test Lab
  • Samsung Developer Conference
  • SDC22
  • Watch Face Studio
All Search Form
Recommendation
    Suggestion
      All Search Form
      Filter
      Filter
      Filter
      • ALL
      • DOCS
      • SDK
      • API REFERENCE (91)
      • CODE LAB
      • BLOG
      • NEWS/EVENTS
      • API REFERENCE
        api reference code lab blog news/events
      1. Develop
      2. Health

      api

      API Reference

      overview package class tree deprecated index samsung health android sdk - data api reference 1.5.0 health data this document describes com.samsung.android.sdk.healthdata apis in samsung health sdk for android. see: description packages package description com.samsung.android.sdk.healthdata this package provides classes and interfaces for the health data framework in samsung health sdk for android. 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.0 6.12 or above 1.4.0 or above 6.2 or above 6.11 or below 1.3.0 5.11 or above6.1 or below 1.2.01.2.1 5.10 1.0.01.1.0 4.0 or above5.9 or below 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. old_version_platform 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: exception handing

      https://developer.samsung.com/health/android/data/api-reference/overview-summary.html
      1. Develop
      2. Health

      api

      HealthDeviceManager

      overview package class tree deprecated index com.samsung.android.sdk.healthdata class healthdevicemanager java.lang.object com.samsung.android.sdk.healthdata.healthdevicemanager public class healthdevicemanager extends object this class provides device information that is registered in the data framework and is able to register a new source device that provides health data. if a new data is saved to samsung health and its source device is new, the source device is registered to the health data framework automatically. a device with samsung health installed is recognized as the local device. registering a new source device separately is availble with healthdevice.builder.build() and registerdevice(healthdevice). the user's device that installed your application can meet many environments like: changing a phone and synchronizing samsung health data with the user's samsung account. all data in the old phone are moved to the new one. using an accessory such as galaxy watch with the phone. a data query need to be requested with varied considerations for your application and target devices. if you want to make that the query result contains only data your intended devices, set data's source devices for the data query such as with setsourcedevices() of healthdataresolver.readrequest.builder. otherwise, the query result can contain unintentional data of registered other accessories to samsung health. getting current device information the current device that samsung health runs is registered as the local device in the health data framework. if your application runs the current device and adds a new data to samsung health, set the data's source device as the local device. the following example shows how to get the current device information. public class heathdataexample { // the state of connection private healthdatastore mstore; void createhealthdata() { healthdata data = new healthdata(); // sets required properties // sets source device's uuid data.setsourcedevice(new healthdevicemanager(mstore).getlocaldevice().getuuid()); // adds new data to samsung health healthdataresolver resolver = new healthdataresolver(mstore, null); insertrequest request = new insertrequest.builder().setdatatype(nutrition.health_data_type).build(); request.addhealthdata(data); } } getting all registered devices' information samsung health works with accessories such as galaxy watch by the user's registration and can save the registered accessory's health data. also your application can work with a linked accessory and inserts its measured data to samsung health. you can get all registered devices to samsung health with getalldevices() and figure out other devices beside the current device that samsung health runs as the following example. //gets the current device healthdevicemanager devicemanager = new healthdevicemanager(mstore); string localuuid = devicemanager.getlocaldevice().getuuid(); // gets all registered devices list<healthdevice> healthdevices = new healthdevicemanager(mstore).getalldevices(); // checks registered devices beside the current device for (healthdevice device : healthdevices) { if (!device.getuuid().equals(localuuid)) { log.d(app_tag, "accessory's uuid: " + device.getuuid()); } } registering device to samsung health if you add data to samsung health and the data's source device is not registered yet on samsung health, register the data's source device before to adding data with registerdevice(healthdevice). since: 1.0.0 constructor summary constructors constructor and description healthdevicemanager(healthdatastore store) constructs and initializes an instance of healthdevicemanager. method summary all methods instance methods concrete methods modifier and type method and description boolean changecustomname(string uuid, string name) changes a custom name of the health device for a given device id. list<healthdevice> getalldevices() gets a list of all source devices in samsung health's saved data. healthdevice getdevicebyseed(string seed) gets a health device specified by a seed. healthdevice getdevicebyuuid(string uuid) gets a health device specified by an uuid. list<string> getdeviceuuidsbycustomname(string name) gets uuids of health devices for a given custom name. list<string> getdeviceuuidsbygroup(int group) gets uuids of devices for a given group. list<string> getdeviceuuidsbymanufacturer(string manufacturer) gets uuids of health devices for a given manufacturer. list<string> getdeviceuuidsbymodel(string model) gets uuids of health devices for a given device model. healthdevice getlocaldevice() gets a healthdevice object of the current device. string registerdevice(healthdevice device) registers a new source device that provides health data to the health data framework. constructor detail healthdevicemanager public healthdevicemanager(healthdatastore store) constructs and initializes an instance of healthdevicemanager. parameters: store - a connection with the health data store since: 1.0.0 method detail getlocaldevice public healthdevice getlocaldevice() gets a healthdevice object of the current device. samsung health sdk for android registers the current device where samsung health is installed. returns: the health device object throws: illegalstateexception - if the connection to the health data store is invalid or a remote-invocation error occurs on the connection since: 1.0.0 getalldevices public list<healthdevice> getalldevices() gets a list of all source devices in samsung health's saved data. it's different with getting all connected devices with samsung health. if a connected device didn't save its data to samsung health, the device is not included in this api's return. because this api gives only all device ids based on the saved data. an accessory that the user removes from samsung health's accessory list can be contained in its result if the accessory's data is saved in samsung health. returns: a list of registered all health device objects throws: illegalstateexception - if the connection to the health data store is invalid or a remote-invocation error occurs on the connection since: 1.0.0 registerdevice public string registerdevice(healthdevice device) registers a new source device that provides health data to the health data framework. parameters: device - the health device object to register returns: the registered device's id throws: illegalargumentexception - if the argument is null illegalstateexception - if the connection to the health data store is invalid or a remote-invocation error occurs on the connection since: 1.0.0 see also: healthdevice.builder.build() getdevicebyseed public healthdevice getdevicebyseed(string seed) gets a health device specified by a seed. parameters: seed - the unique value that identifies the device. it can be a wi-fi mac address, bluetooth address, or device's serial number. returns: a health device object for the seed throws: illegalargumentexception - if the argument is null illegalstateexception - if the connection to the health data store is invalid or a remote-invocation error occurs on the connection since: 1.0.0 getdevicebyuuid public healthdevice getdevicebyuuid(string uuid) gets a health device specified by an uuid. parameters: uuid - the uuid that represents the device returns: a health device object for the uuid throws: illegalargumentexception - if the argument is null illegalstateexception - if the connection to the health data store is invalid or a remote-invocation error occurs on the connection since: 1.0.0 getdeviceuuidsbygroup public list<string> getdeviceuuidsbygroup(int group) gets uuids of devices for a given group. parameters: group - the device group. it can be the following value. healthdevice.group_unknown healthdevice.group_mobile healthdevice.group_external healthdevice.group_companion returns: a list of uuids for devices that are specified with the group throws: illegalstateexception - if the connection to the health data store is invalid or a remote-invocation error occurs on the connection since: 1.0.0 getdeviceuuidsbycustomname public list<string> getdeviceuuidsbycustomname(string name) gets uuids of health devices for a given custom name. parameters: name - the custom name returns: a list of uuids for devices that are specified with the custom name. throws: illegalargumentexception - if the argument is null illegalstateexception - if the connection to the health data store is invalid or a remote-invocation error occurs on the connection since: 1.0.0 getdeviceuuidsbymodel public list<string> getdeviceuuidsbymodel(string model) gets uuids of health devices for a given device model. parameters: model - the model name returns: a list of uuids for devices that are specified with the model name throws: illegalargumentexception - if the argument is null illegalstateexception - if the connection to the health data store is invalid or a remote-invocation error occurs on the connection since: 1.0.0 getdeviceuuidsbymanufacturer public list<string> getdeviceuuidsbymanufacturer(string manufacturer) gets uuids of health devices for a given manufacturer. parameters: manufacturer - the manufacturer name returns: a list of uuids for devices that are specified with the manufacturer throws: illegalargumentexception - if the argument is null illegalstateexception - if the connection to the health data store is invalid or a remote-invocation error occurs on the connection since: 1.0.0 changecustomname public boolean changecustomname(string uuid, string name) changes a custom name of the health device for a given device id. parameters: uuid - the device id name - the new custom name of the device returns: true if the change is successful, or false if otherwise throws: illegalargumentexception - if the argument is null illegalstateexception - if the connection to the health data store is invalid or a remote-invocation error occurs on the connection since: 1.0.0

      https://developer.samsung.com/health/android/data/api-reference/com/samsung/android/sdk/healthdata/HealthDeviceManager.html
      1. Develop
      2. Health

      api

      HealthDataResolver

      overview package class tree deprecated index com.samsung.android.sdk.healthdata class healthdataresolver java.lang.object com.samsung.android.sdk.healthdata.healthdataresolver public class healthdataresolver extends object this class is able to access health data to insert, read, update, and delete with the specified filter and some aggregate functions. data management health data can be accessed with following interfaces mainly. healthdataresolver.insertrequest healthdataresolver.readrequest healthdataresolver.updaterequest healthdataresolver.deleterequest healthdataresolver.aggregaterequest filter handling a part of data is a common use case rather than accessing whole data for the health data type. the health data framework provides a filter to specify the precise scope for health data and is able to access required data only. healthdataresolver.filter asynchronous data request the asynchronous request is used normally for operations that take a time such as reading data with conditions. if you need to request asynchronously, set the result listener with healthresultholder.setresultlistener(healthresultholder.resultlistener). the following example shows how to make an asynchronous request. public class healthdataresolverexample { // the state of connection healthdatastore mstore; public static final string app_tag = "myapp"; public void readglucoseasynchronously(long starttime, long endtime) { healthdataresolver resolver = new healthdataresolver(mstore, null); healthdataresolver.readrequest request = new healthdataresolver.readrequest.builder() .setdatatype(healthconstants.bloodglucose.health_data_type) .setlocaltimerange(healthconstants.bloodglucose.start_time, healthconstants.bloodglucose.time_offset, starttime, endtime) .build(); try { resolver.read(request).setresultlistener(mrdresult); } catch (exception e) { log.d(app_tag, "reading health data fails."); } } private final healthresultholder.resultlistener<healthdataresolver.readresult> mrdresult = new healthresultholder.resultlistener<healthdataresolver.readresult>(){ @override public void onresult(healthdataresolver.readresult result) { try { iterator<healthdata> iterator = result.iterator(); if (iterator.hasnext()) { healthdata data = iterator.next(); float glucosevalue = data.getfloat(healthconstants.bloodglucose.glucose); } finally { result.close(); } }; } synchronous datarequest though asynchronous data request is used commonly, there is a way to get the query result synchronously with healthresultholder.await(). note, not to make the synchronous request on the ui thread. healthresultholder.await() throws an exception if it is called on the main thread. it can hang your application caused by taking a time to handle the synchronous query. the following example shows how to make a synchronous request. public class healthdataresolverexample { // the state of connection healthdatastore mstore; public static final string app_tag = "myapp"; public void readglucosesynchronously(long starttime, long endtime) { healthdataresolver resolver = new healthdataresolver(mstore, null); healthdataresolver.readrequest request = new healthdataresolver.readrequest.builder() .setdatatype(healthconstants.bloodglucose.health_data_type) .setlocaltimerange(healthconstants.bloodglucose.start_time, healthconstants.bloodglucose.time_offset, starttime, endtime) .build(); try { // checks the result immediately healthdataresolver.readresult rdresult = resolver.read(request).await(); try { iterator<healthdata> iterator = rdresult.iterator(); if (iterator.hasnext()) { healthdata data = iterator.next(); float glucosevalue = data.getfloat(healthconstants.bloodglucose.glucose); } finally { rdresult.close(); } } catch (exception e) { log.d(app_tag, "reading health data fails."); } } } acquiring data permission getting data permission is required after connection to the health data store to synchronize health data with samsung health. samsung health sdk for android provides the data permission ui to get the user's consent. the user can agree to share health data with the application through the permission ui and the application can get required data permission check healthpermissionmanager to use the permission ui. if you try to read or write health data without permission, the sdk gives securityexception. acquiring instant data permission gaining the healthconstants.healthdocument type's permission is different with other data types. it is available by acquiring the instant permission. instant permission is created for one-time data access. it is proper to handle very sensitive health data. the data type needs the instant permission is healthconstants.healthdocument. an app needs the instant permission whenever it accesses health document data. healthdataresolver.insertwithpermission() healthdataresolver.readwithpermission() healthdataresolver.deletewithpermission() if you call healthdataresolver.readwithpermission(), its permission pop-up is shown. the user can select one or more health documents in the list and read the selected document. class relationship of healthdataresolver see a relationship of healthdataresolver with other classes. since: 1.0.0 nested class summary nested classes modifier and type class and description static interface healthdataresolver.aggregaterequest this interface represents an aggregate request with aggregate functions and the specified time unit to group result values. static class healthdataresolver.aggregateresult this class represents the result of healthdataresolver.aggregaterequest. static interface healthdataresolver.deleterequest this interface is able to make a request to delete health data for the specific health data type. static class healthdataresolver.filter this class creates a filter to make the request range clear. static interface healthdataresolver.insertrequest this interface is able to make a request to insert health data for the specific health data type. static interface healthdataresolver.readrequest this interface is able to make a request to read health data for the specific health data type. static class healthdataresolver.readresult this class represents the result for healthdataresolver.readrequest. static class healthdataresolver.sortorder this enum defines sort orders. static interface healthdataresolver.updaterequest this interface is able to make a request to update health data for the specific health data type. constructor summary constructors constructor and description healthdataresolver(healthdatastore store, handler handler) creates a healthdataresolver instance. method summary all methods instance methods concrete methods modifier and type method and description healthresultholder<healthdataresolver.aggregateresult> aggregate(healthdataresolver.aggregaterequest request) aggregates health data with the given request. healthresultholder<healthresultholder.baseresult> delete(healthdataresolver.deleterequest request) deletes health data with the given request. healthresultholder<healthresultholder.baseresult> deletewithpermission(healthdataresolver.deleterequest request, activity activity) deletes health data required instant permission with the given request. healthresultholder<healthresultholder.baseresult> insert(healthdataresolver.insertrequest request) inserts new health data with the given request. healthresultholder<healthresultholder.baseresult> insertwithpermission(healthdataresolver.insertrequest request, activity activity) inserts new health data required instant permission with the given request. healthresultholder<healthdataresolver.readresult> read(healthdataresolver.readrequest request) reads health data with the given request. healthresultholder<healthdataresolver.readresult> readwithpermission(healthdataresolver.readrequest request, activity activity) reads health data required instant permission with the given request. healthresultholder<healthresultholder.baseresult> update(healthdataresolver.updaterequest request) updates health data with the given request. constructor detail healthdataresolver public healthdataresolver(healthdatastore store, handler handler) creates a healthdataresolver instance. parameters: store - the health data store for connection handler - the handler for the proceeding thread. if it's null, the looper of the current thread will be used. since: 1.0.0 method detail insert public healthresultholder<healthresultholder.baseresult> insert(healthdataresolver.insertrequest request) inserts new health data with the given request. it can be implemented asynchronously or synchronously. check this request's result in healthresultholder.baseresult.getstatus(). parameters: request - the request to insert new health data returns: the healthresultholder instance which resolves to the healthresultholder.baseresult for inserted health data throws: illegalargumentexception - if the request contains invalid instance type or null. securityexception - if there is no permission to write for given health data illegalstateexception - if the instance of health data store is invalid or a remote-invocation error occurs on the connection since: 1.0.0 insertwithpermission public healthresultholder<healthresultholder.baseresult> insertwithpermission(healthdataresolver.insertrequest request, activity activity) inserts new health data required instant permission with the given request. calling this method, a file chooser is shown to acquire the user consent. after the user chooses all or some of files, those are finally inserted. it can be implemented asynchronously or synchronously. check this request's result in healthresultholder.baseresult.getstatus(). parameters: request - the request to insert new health data activity - the activity that pop up the permission ui returns: the healthresultholder instance which resolves to the healthresultholder.baseresult for inserted health data throws: illegalargumentexception - if the request contains invalid instance typeor null. illegalstateexception - if the instance of health data store is invalid or a remote-invocation error occurs on the connection since: 1.3.0 update public healthresultholder<healthresultholder.baseresult> update(healthdataresolver.updaterequest request) updates health data with the given request. it can be implemented asynchronously or synchronously. check this request's result through healthresultholder.baseresult.getstatus(). parameters: request - the request to update health data returns: the healthresultholder instance which resolves to the healthresultholder.baseresult for updated health data throws: illegalargumentexception - if the request contains invalid instance typeor null. securityexception - if there is no permission to write for given health data illegalstateexception - if the instance of health data store is invalid or a remote-invocation error occurs on the connection since: 1.0.0 delete public healthresultholder<healthresultholder.baseresult> delete(healthdataresolver.deleterequest request) deletes health data with the given request. it can be implemented asynchronously or synchronously. parameters: request - the request to delete health data returns: the healthresultholder instance which resolves to the healthresultholder.baseresult for deleted health data throws: illegalargumentexception - if the request contains invalid instance type or null securityexception - if there is no permission to write for given health data illegalstateexception - if the instance of health data store is invalid or a remote-invocation error occurs on the connection since: 1.0.0 deletewithpermission public healthresultholder<healthresultholder.baseresult> deletewithpermission(healthdataresolver.deleterequest request, activity activity) deletes health data required instant permission with the given request. calling this method, a file chooser is shown to acquire the user consent. after the user chooses all or some of files, those are finally deleted. it can be implemented asynchronously or synchronously. parameters: request - the request to delete health data activity - the activity that pop up the permission ui returns: the healthresultholder instance which resolves to the healthresultholder.baseresult for deleted health data throws: illegalargumentexception - if the request contains invalid instance type or null illegalstateexception - if the instance of health data store is invalid or a remote-invocation error occurs on the connection since: 1.3.0 read public healthresultholder<healthdataresolver.readresult> read(healthdataresolver.readrequest request) reads health data with the given request. it can be implemented asynchronously or synchronously. parameters: request - the request to read health data returns: the healthresultholder instance which resolves to the healthdataresolver.readresult for health data to read throws: illegalargumentexception - if the request contains invalid instance type or null securityexception - if there is no permission to read for given health data illegalstateexception - if the instance of health data store is invalid or a remote-invocation error occurs on the connection since: 1.0.0 readwithpermission public healthresultholder<healthdataresolver.readresult> readwithpermission(healthdataresolver.readrequest request, activity activity) reads health data required instant permission with the given request. calling this method, a file chooser is shown to acquire the user consent. after the user chooses all or some of files, those are finally read. it can be implemented asynchronously or synchronously. parameters: request - the request to read health data activity - the activity that pop up the permission ui returns: the healthresultholder instance which resolves to the healthdataresolver.readresult for health data to read throws: illegalargumentexception - if the request contains invalid instance type or null illegalstateexception - if the instance of health data store is invalid or a remote-invocation error occurs on the connection since: 1.3.0 aggregate public healthresultholder<healthdataresolver.aggregateresult> aggregate(healthdataresolver.aggregaterequest request) aggregates health data with the given request. it can be implemented asynchronously or synchronously. parameters: request - the aggregate request for health data returns: the healthdataresolver.aggregateresult instance which resolves to the healthdataresolver.readresult for the requested aggregate throws: illegalargumentexception - if the request contains invalid instance type or null securityexception - if there is no permission to read for given health data illegalstateexception - if the instance of health data store is invalid or a remote-invocation error occurs on the connection since: 1.0.0

      https://developer.samsung.com/health/android/data/api-reference/com/samsung/android/sdk/healthdata/HealthDataResolver.html
      1. Develop
      2. Health

      api

      HealthData

      overview package class tree deprecated index com.samsung.android.sdk.healthdata class healthdata java.lang.object com.samsung.android.sdk.healthdata.healthdata all implemented interfaces: parcelable public final class healthdata extends object implements parcelable this class presents a health data object for a specified health data type, e.g. the blood pressure or weight. handling health data quantitative and qualitative values of health data can be specified through this class. set each property value of health data based on its data type definition and manage it with healthdataresolver. the data type definitions are described in samsung health's data types. example see inserting health data. since: 1.0.0 constructor summary constructors constructor and description healthdata() creates a health data instance. method summary all methods instance methods concrete methods modifier and type method and description void clear() clears values of all properties in the health data object. byte[] getblob(string key) gets a blob value associated with a given property. double getdouble(string key) gets a double value associated with a given property. float getfloat(string key) gets a float value associated with a given property. inputstream getinputstream(string key) gets an inputstream associated with a given property. int getint(string key) gets an integer value associated with a given property. long getlong(string key) gets a long value associated with a given property. string getsourcedevice() gets the source device which provides health data. string getstring(string key) gets a text value associated with a given property. string getuuid() gets the unique id of the object. void putblob(string key, byte[] value) inserts a blob value into a given property of the health data object. void putdouble(string key, double value) puts a double value into the given property of the health data object. void putfloat(string key, float value) puts a float value into a given property of the health data object. void putinputstream(string key, inputstream value) inserts an inputstream into a given property of the health data object. void putint(string key, int value) puts an integer value into a given property of the health data object. void putlong(string key, long value) puts a long value into a given property of the health data object. void putnull(string key) inserts a null value into a given property of the health data object. void putstring(string key, string value) puts a text value into a given property of the health data object. void setsourcedevice(string deviceuuid) sets the source device which provides health data. constructor detail healthdata public healthdata() creates a health data instance. since: 1.0.0 method detail getuuid public string getuuid() gets the unique id of the object. use getstring() to get the data's uuid from a result in: healthdataresolver.aggregateresult healthdataresolver.readresult returns: the unique id contained in the object throws: unsupportedoperationexception - if the health data is in healthdataresolver.aggregateresult or healthdataresolver.readresult since: 1.0.0 getsourcedevice public string getsourcedevice() gets the source device which provides health data. returns: the id of the source device which provides health data since: 1.0.0 setsourcedevice public void setsourcedevice(string deviceuuid) sets the source device which provides health data. it's mandatory to set the source device for created health data. parameters: deviceuuid - the source device id which provides health data since: 1.0.0 getstring public string getstring(string key) gets a text value associated with a given property. parameters: key - the specific property name of health data that its value type is text. e.g. healthconstants.exercise.comment returns: the text value, or null if the health data object does not have the given property since: 1.0.0 getfloat public float getfloat(string key) gets a float value associated with a given property. parameters: key - the specific property name of health data that its value type is float. e.g. healthconstants.exercise.distance returns: the float value, or 0.0f if the health data object does not have the given property since: 1.0.0 getdouble public double getdouble(string key) gets a double value associated with a given property. parameters: key - the specific property name of health data that its value type is double returns: the double value, or 0.0d if the desired type does not exist for the given property since: 1.0.0 getlong public long getlong(string key) gets a long value associated with a given property. parameters: key - the specific property name of health data that its value type is long. e.g. healthconstants.exercise.duration returns: the long value, or 0l if the desired type does not exist for the given property since: 1.0.0 getint public int getint(string key) gets an integer value associated with a given property. parameters: key - the specific property name of health data that its value type is integer. e.g. healthconstants.bloodglucose.measurement_type returns: the integer value, or 0 if the desired type does not exist for the given property since: 1.0.0 getblob public byte[] getblob(string key) gets a blob value associated with a given property. parameters: key - the specific property name of health data that its value type is blob. e.g. healthconstants.exercise.live_data returns: the blob value, or null if the desired type does not exist for the given property since: 1.0.0 getinputstream public inputstream getinputstream(string key) gets an inputstream associated with a given property. parameters: key - the specific property name of health data that its value type is file. e.g. healthconstants.healthdocument.document returns: the inputstream object, or null if the desired type does not exist for the given property since: 1.3.0 putint public void putint(string key, int value) puts an integer value into a given property of the health data object. the existing value for the property is replaced. parameters: key - the health data's specific property name that its value type is integer. e.g. healthconstants.bloodglucose.measurement_type value - the integer value for the given property since: 1.0.0 putlong public void putlong(string key, long value) puts a long value into a given property of the health data object. the existing value for the property is replaced. parameters: key - the health data's specific property name that its value type is long. e.g. healthconstants.exercise.duration value - the long value for the given property since: 1.0.0 putfloat public void putfloat(string key, float value) puts a float value into a given property of the health data object. the existing value for the property is replaced. parameters: key - the health data's specific property name that its value type is float. e.g. healthconstants.exercise.distance value - the float value for the given property since: 1.0.0 putdouble public void putdouble(string key, double value) puts a double value into the given property of the health data object. the existing value for the property is replaced. parameters: key - the health data's specific property name that its value type is double value - the double value for the given property since: 1.0.0 putstring public void putstring(string key, string value) puts a text value into a given property of the health data object. the existing value for the property is replaced. parameters: key - the health data's specific property name that its value type is text. e.g. healthconstants.exercise.comment value - the text value for the given property since: 1.0.0 putblob public void putblob(string key, byte[] value) inserts a blob value into a given property of the health data object. the existing value for the property is replaced. parameters: key - the health data's specific property name that its value type is blob e.g. healthconstants.exercise.live_data value - the blob value for the given property since: 1.0.0 putinputstream public void putinputstream(string key, inputstream value) inserts an inputstream into a given property of the health data object. the existing value for the property is replaced. parameters: key - the health data's specific property name that its value type is file e.g. healthconstants.healthdocument.document value - the inputstream object for the given property since: 1.3.0 putnull public void putnull(string key) inserts a null value into a given property of the health data object. the existing value for the property is replaced. parameters: key - the health data's specific property name since: 1.1.0 clear public void clear() clears values of all properties in the health data object. since: 1.0.0

      https://developer.samsung.com/health/android/data/api-reference/com/samsung/android/sdk/healthdata/HealthData.html
      1. Develop
      2. Health

      api

      HealthConnectionErrorResult

      overview package class tree deprecated index com.samsung.android.sdk.healthdata class healthconnectionerrorresult java.lang.object com.samsung.android.sdk.healthdata.healthconnectionerrorresult public final class healthconnectionerrorresult extends object this class handles errors raised by connection failure to the health data store. considerations for connection failure a partner app works with samsung health. the partner app can meet the following error cases when it connects to samsung health. connection error description platform_not_installed samsung health is not installed. old_version_platform installed samsung health's version is old. platform_disabled samsung health is disabled. user_agreement_needed the user didn't agree to samsung health's terms & conditions and privacy policies. user_password_needed samsung health is locked by the user password. handling connection exceptions samsung health sdk for android helps you to handle all available error cases with healthconnectionerror when your application connects to the health data store. healthconnectionerror is retrieved in healthdatastore.connectionlistener's event handler and all samsung health's partner applications need to check the health data store's connection error mandatorily. the following example shows how to handle the connection error. public class mainactivity extends activity { private healthdatastore mstore; private healthconnectionerrorresult mconnerror; private static mainactivity minstance = null; @override public void oncreate(bundle savedinstancestate) { // ... mstore = new healthdatastore(this, mconnectionlistener); mstore.connectservice(); } @override public void ondestroy() { mstore.disconnectservice(); // ... } private final healthdatastore.connectionlistener mconnectionlistener = new healthdatastore.connectionlistener() { @override public void onconnected() { // connected } @override public void onconnectionfailed(healthconnectionerrorresult error) { // connection fails showconnectionfailuredialog(error); } @override public void ondisconnected() { // connection is disconnected } }; private void showconnectionfailuredialog(healthconnectionerrorresult error) { alertdialog.builder alert = new alertdialog.builder(this); mconnerror = error; if (mconnerror.hasresolution()) { switch(error.geterrorcode()) { case healthconnectionerrorresult.platform_not_installed: message = "please install samsung health"; break; case healthconnectionerrorresult.old_version_platform: message = "please upgrade samsung health"; break; case healthconnectionerrorresult.platform_disabled: message = "please enable samsung health"; break; case healthconnectionerrorresult.user_agreement_needed: message = "please agree to samsung health policy"; break; default: message = "please make samsung health available"; break; } } else { // in case that the device doesn't support samsung health, // hasresolution() returns false also. alert.setmessage(r.string.msg_conn_not_available); } alert.setpositivebutton(r.string.ok, (dialog, id) -> { if (error.hasresolution()) { error.resolve(mainactivity.this); } }); if (error.hasresolution()) { alert.setnegativebutton("cancel", null); } alert.show(); } } since: 1.0.0 see also: healthdatastore.connectionlistener field summary fields modifier and type field and description static int connection_failure the connection is not established in the health data framework. static int old_version_platform the version of the health data framework is outdated to cooperate with sdk. static int old_version_sdk the sdk's data library version is outdated to cooperate with the samsung health's health data framework. static int platform_disabled the health data framework is disabled. static int platform_not_installed samsung health is not installed. static int platform_signature_failure it fails to check the signature of the health data framework. static int timeout the connection time exceeded the limit. static int unknown unknown error. static int user_agreement_needed the user did not agree to terms and conditions, and privacy policy of samsung health yet. static int user_password_needed the user cancels the password input explicitly on the password pop-up window. method summary all methods instance methods concrete methods modifier and type method and description int geterrorcode() gets the error code of connection failure. boolean hasresolution() checks whether the given error has a resolution. void resolve(activity activity) resolves an error with an activity which is able to get the user's feedback for possible error cases. field detail unknown public static final int unknown unknown error. its constant value is 0. since: 1.0.0 see also: constant field values connection_failure public static final int connection_failure the connection is not established in the health data framework. its constant value is 1. since: 1.0.0 see also: constant field values platform_not_installed public static final int platform_not_installed samsung health is not installed. to resolve it: if your app runs on android 11, check your app manifest whether the "<queries>" element is added. see the app manifest guide. call resolve(android.app.activity). it leads the user to install samsung health on an app seller site. its constant value is 2. since: 1.0.0 see also: resolve(android.app.activity), constant field values old_version_sdk public static final int old_version_sdk the sdk's data library version is outdated to cooperate with the samsung health's health data framework. to resolve it: apply the latest data library to your app. if your app uses the latest data library, create an activity to update to install your latest app. its constant value is 3. since: 1.0.0 see also: constant field values old_version_platform public static final int old_version_platform the version of the health data framework is outdated to cooperate with sdk. to resolve it, call resolve(android.app.activity). it leads the user to install the latest samsung health on an app seller site. its constant value is 4. since: 1.0.0 see also: resolve(android.app.activity), constant field values timeout public static final int timeout the connection time exceeded the limit. its constant value is 5. since: 1.0.0 see also: constant field values platform_disabled public static final int platform_disabled the health data framework is disabled. to resolve it, call resolve(android.app.activity). it leads the user to activate samsung health through the phone's settings. its constant value is 6. since: 1.0.0 see also: resolve(android.app.activity), constant field values user_password_needed public static final int user_password_needed the user cancels the password input explicitly on the password pop-up window. some devices can request a password to protect the user's data. the password for the health data access can be registered in samsung health by the user. then the user can enter the password through the password pop-up window. if the predetermined time passed without the valid password input, timeout occurs. its constant value is 7. since: 1.0.0 see also: constant field values platform_signature_failure public static final int platform_signature_failure it fails to check the signature of the health data framework. its constant value is 8. since: 1.0.0 see also: constant field values user_agreement_needed public static final int user_agreement_needed the user did not agree to terms and conditions, and privacy policy of samsung health yet. the health data framework is not activated before agreement. to resolve it, call reslove. it leads the user to the samsung health's service agreement page. its constant value is 9. since: 1.0.0 see also: resolve(android.app.activity), constant field values method detail geterrorcode public int geterrorcode() gets the error code of connection failure. usually it is called in healthdatastore.connectionlistener.onconnectionfailed(healthconnectionerrorresult). it's required to resolve the error depending on its returned error code. returns: the error code since: 1.0.0 hasresolution public boolean hasresolution() checks whether the given error has a resolution. whether the device supports samsung health the sdk supports marshmallow and above android devices including non-samsung devices. and it works with samsung health. there is no connection issue on most devices but it is not available occasionally depending on the device's specification. this api lets you know whether the device supports samsung health. the returned false involves that the device is not available for samsung health. precondition: check the network connection. permission: android.permission.internet returns: true if the platform provides a resolution for the error. call resolve(activity). false in the following cases: if the device doesn't support samsung health if there is no resolution for the error since: 1.0.0 resolve public void resolve(activity activity) resolves an error with an activity which is able to get the user's feedback for possible error cases. it handles the following errors and operations. show a proper message for each error case in your application before call this method. error operation platform_not_installed linked to the application installation page old_version_platform linked to the application installation page platform_disabled linked to settings of the device to turn on samsung health user_agreement_needed linked to the starting screen of samsung health to get the user's agreement precondition: check the network connection. permission: android.permission.internet parameters: activity - an activity which resolves the error with the user's feedback. usually it's the main activity of your application. throws: illegalargumentexception - if the specified input is null or invalid since: 1.0.0

      https://developer.samsung.com/health/android/data/api-reference/com/samsung/android/sdk/healthdata/HealthConnectionErrorResult.html
      1. Develop
      2. Health

      api

      HealthDataResolver.InsertRequest

      overview package class tree deprecated index com.samsung.android.sdk.healthdata interface healthdataresolver.insertrequest enclosing class: healthdataresolver public static interface healthdataresolver.insertrequest this interface is able to make a request to insert health data for the specific health data type. request for inserting data healthdataresolver.insert() helps that your application saves a new measured data to samsung health. the following information is mandatory to build an insertrequest instance. mandatory information description data type set the data type with: insertrequest.builder.setdatatype() source device the device id that provides health data. set it with: healthdata.setsourcedevice() data's mandatory properties set mandatory properties of the health data type by referring to: data type definition you can make a request instance with insertrequest.builder.build(). inserting data example you can save health data to samsung health with healthdataresolver.insert() after setting detailed property values of the created healthdata instance. the health data framework registers the current device where your application is installed. if the source device is the current device, its id can be checked as shown below. // the state of connection private final healthdatastore mstore; public static final string app_tag = "myapp"; private void insertglucose(long start, long offset, float value) { // set the source device as the current device healthdevice mydevice = new healthdevicemanager(mstore).getlocaldevice(); healthdata data = new healthdata(); data.setsourcedevice(mydevice.getuuid()); and the data instance's properties including mandatory ones needs to be set. // set properties including mandatory ones data.putlong(healthconstants.bloodglucose.start_time, start); data.putlong(healthconstants.bloodglucose.time_offset, offset); data.putint(healthconstants.bloodglucose.measurement_type, healthconstants.bloodglucose.measurement_type_whole_blood); the measured data value needs to be set after checking defined data unit. each property in api reference lets you know it. in this case, see healthconstants.bloodglucose.glucose data.putfloat(healthconstants.bloodglucose.glucose, value); an insertrequest instance is created by insertrequest.builder.build() with setting the data type. it's ready to add data to samsung health if the data is added to the insertrequest. healthdataresolver.insertrequest insrequest = new healthdataresolver.insertrequest.builder() .setdatatype(healthconstants.bloodglucose.health_data_type) .build(); // add health data insrequest.addhealthdata(data); healthdataresolver resolver = new healthdataresolver(mstore, null); try { resolver.insert(insrequest).setresultlistener(mistresult); } catch (exception e) { log.d(app_tag, "resolver.insert() fails."); } } healthdataresolver.insert(com.samsung.android.sdk.healthdata.healthdataresolver.insertrequest) sends a request to samsung health. a data validation exception is received in healthresultholder.baseresult. it gives a request's result state and a number of inserted data. private final healthresultholder.resultlistener<healthresultholder.baseresult> mistresult = new healthresultholder.resultlistener<healthresultholder.baseresult>(){ @override public void onresult(healthresultholder.baseresult result) { if(result.getstatus() != status_successful) { // check the error } else { // check the count of inserted data log.d(app_tag, "count of inserted data: " + result.getcount()); } } }; since: 1.0.0 nested class summary nested classes modifier and type interface and description static class healthdataresolver.insertrequest.builder this class is a builder to configure healthdataresolver.insertrequest. method summary all methods instance methods abstract methods modifier and type method and description void addhealthdata(healthdata object) adds health data to insert. void addhealthdata(list<healthdata> objectlist) adds a health data list to insert. method detail addhealthdata void addhealthdata(healthdata object) adds health data to insert. parameters: object - the health data instance. the source device of object should be valid. throws: illegalargumentexception - if source device is not set or data is null since: 1.0.0 addhealthdata void addhealthdata(list<healthdata> objectlist) adds a health data list to insert. parameters: objectlist - the list of health data objects. the source device for each health data has to be defined in advance. throws: illegalargumentexception - if source device is not set or data list is null since: 1.0.0

      https://developer.samsung.com/health/android/data/api-reference/com/samsung/android/sdk/healthdata/HealthDataResolver.InsertRequest.html
      1. Develop
      2. Health

      api

      HealthDataObserver

      overview package class tree deprecated index com.samsung.android.sdk.healthdata class healthdataobserver java.lang.object com.samsung.android.sdk.healthdata.healthdataobserver public abstract class healthdataobserver extends object this class defines a health data observer for health data change. adding an observer you can add an observer for the specific health data type and get notification in onchange(string) if the designated health data is changed. in case that you add an observer for the data type that updates too frequently in short time like step count, it can send too many events to your application and it can bring degradation of your application's performance. check that your application needs to update data with real-time from samsung health again before adding an observer. a health data observer can be defined as below. public class healthdataobserverexample { // the state of connection private healthdatastore mstore; public static final string app_tag = "myapp"; private final healthdataobserver mobserver = new healthdataobserver(null) { // checks notification for changed health data @override public void onchange(string datatypename) { log.d(app_tag, "health data is changed."); readchangeddata(datatypename); } }; when you add an observer for the specific health data type, specify the data type name as below. only data type is allowed to be observed. public void start() { // adds an observer for change of the weight healthdataobserver.addobserver(mstore, healthconstants.weight.health_data_type, mobserver); } the change notification is received in onchange(string) and you can check updated health data as below. private void readchangeddata(string datatypename) { healthdataresolver resolver = new healthdataresolver(mstore, null); healthdataresolver.readrequest rdrequest = new healthdataresolver.readrequest.builder() .setdatatype(datatypename) .build(); try { // make an asynchronous request to read health data resolver.read(rdrequest).setresultlistener(mrdlistener); } catch (exception e) { log.d(app_tag, "healthdataresolver.read() fails."); } } private final healthresultholder.resultlistener<healthdataresolver.readresult> mrdlistener = new healthresultholder.resultlistener<healthdataresolver.readresult>() { @override public void onresult(healthdataresolver.readresult result) { try { iterator<healthdata> iterator = result.iterator(); if (iterator.hasnext()) { healthdata data = iterator.next(); // check the result } } finally { result.close(); } } }; } since: 1.0.0 constructor summary constructors constructor and description healthdataobserver(handler handler) creates a healthdataobserver instance. method summary all methods static methods instance methods abstract methods concrete methods modifier and type method and description static void addobserver(healthdatastore store, string datatypename, healthdataobserver observer) adds an observer that wants to follow data change for the given health data type. abstract void onchange(string datatypename) called if health data registered as an observer is changed. static void removeobserver(healthdatastore store, healthdataobserver observer) removes a registered observer. constructor detail healthdataobserver public healthdataobserver(handler handler) creates a healthdataobserver instance. parameters: handler - the handler to run onchange(string). if it's null, onchange(string) event is run on binder thread which is invoked by samsung health. since: 1.0.0 method detail onchange public abstract void onchange(string datatypename) called if health data registered as an observer is changed. parameters: datatypename - the data type name that health data is changed since: 1.0.0 addobserver public static void addobserver(healthdatastore store, string datatypename, healthdataobserver observer) adds an observer that wants to follow data change for the given health data type. parameters: store - the health data store for connection datatypename - the health data type name to follow change observer - an observer to receive notification if health data is changed throws: illegalargumentexception - if the data type or observer is invalid illegalstateexception - if the instance of health data store is invalid or a remote-invocation error occurs in the connection since: 1.0.0 removeobserver public static void removeobserver(healthdatastore store, healthdataobserver observer) removes a registered observer. parameters: store - health data store for connection observer - the added observer throws: illegalargumentexception - if the observer is invalid illegalstateexception - if the instance of health data store is invalid or a remote-invocation error occurs in the connection since: 1.0.0

      https://developer.samsung.com/health/android/data/api-reference/com/samsung/android/sdk/healthdata/HealthDataObserver.html
      1. Develop
      2. Health

      api

      HealthDataStore

      overview package class tree deprecated index com.samsung.android.sdk.healthdata class healthdatastore java.lang.object com.samsung.android.sdk.healthdata.healthdatastore public class healthdatastore extends object this class provides connection to the health data store. app manifest from android 11, add the following element in your app's manifest. otherwise, a connection with samsung health fails. <manifest . . . > <queries> <package android:name="com.sec.android.app.shealth" /> </queries> </manifest> data store connection health data in the health data store can be accessed after getting connection with the health data store. healthdatastore requests to connect or disconnect with the health data store and its result can be checked with healthdatastore.connectionlistener. an example below shows how to request connection to the health data store and check the result. public class mainactivity extends activity { // the state of connection private healthdatastore mstore; private static final string app_tag = "myapp"; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); connect(); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate the menu; this adds items to the action bar if it is present. getmenuinflater().inflate(r.menu.main, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { // handle action bar item clicks here. the action bar will // automatically handle clicks on the home/up button, so long // as you specify a parent activity in androidmanifest.xml. int id = item.getitemid(); if (id == r.id.action_settings) { return true; } return super.onoptionsitemselected(item); } public healthdatastore connect() { // connect to the health data store mstore = new healthdatastore(this, mcntlistener); try { mstore.connectservice(); } catch (exception e) { log.d(app_tag, "connection fails."); e.printstacktrace(); } return mstore; } private final healthdatastore.connectionlistener mcntlistener = new healthdatastore.connectionlistener() { @override public void onconnected() { log.d(app_tag, "health data service is connected."); } @override public void onconnectionfailed(healthconnectionerrorresult error) { if (error.hasresolution()) { // resolve an error } else { log.d(app_tag, "health data service is not available."); } } @override public void ondisconnected() { log.d(app_tag, "health data service is disconnected."); } }; } since: 1.0.0 nested class summary nested classes modifier and type class and description static interface healthdatastore.connectionlistener this interface provides the callback when the client is connected or disconnected with the health data store. constructor summary constructors constructor and description healthdatastore(context context, healthdatastore.connectionlistener listener) constructs and initializes an instance of healthdatastore with a context and listener. method summary all methods instance methods concrete methods modifier and type method and description void connectservice() connects your application to the health data store. void connectservice(long timeout) connects your application to the health data store for the given connection timeout. void disconnectservice() disconnects your application from the health data store. constructor detail healthdatastore public healthdatastore(context context, healthdatastore.connectionlistener listener) constructs and initializes an instance of healthdatastore with a context and listener. parameters: context - the context of application listener - the listener that is implemented to receive the result of the connection or disconnection request. throws: illegalargumentexception - if the given context or listener is null since: 1.0.0 method detail connectservice public void connectservice() connects your application to the health data store. it tries connection for one minute in default. if you want to set a connection timeout differently, use connectservice(long). the connection result can be checked in the following handlers. healthdatastore.connectionlistener.onconnected() is invoked if it succeeds. healthdatastore.connectionlistener.onconnectionfailed(healthconnectionerrorresult) is invoked if it fails. throws: illegalstateexception - if the instance is not constructed with a valid context instance since: 1.0.0 connectservice public void connectservice(long timeout) connects your application to the health data store for the given connection timeout. the connection result can be checked in the following handlers. healthdatastore.connectionlistener.onconnected() is invoked if it succeeds. healthdatastore.connectionlistener.onconnectionfailed(healthconnectionerrorresult) is invoked if it fails. parameters: timeout - the timeout value in milliseconds for connection to health data store. if connection doesn't succeed in timeout, healthdatastore.connectionlistener.onconnectionfailed(healthconnectionerrorresult) is invoked. throws: illegalstateexception - if the instance is not constructed with a valid context instance since: 1.0.0 disconnectservice public void disconnectservice() disconnects your application from the health data store. note that healthdatastore.connectionlistener.ondisconnected() is not invoked after calling this method. since: 1.0.0

      https://developer.samsung.com/health/android/data/api-reference/com/samsung/android/sdk/healthdata/HealthDataStore.html
      1. Develop
      2. Health

      api

      HealthDataStore.ConnectionListener

      overview package class tree deprecated index com.samsung.android.sdk.healthdata interface healthdatastore.connectionlistener enclosing class: healthdatastore public static interface healthdatastore.connectionlistener this interface provides the callback when the client is connected or disconnected with the health data store. since: 1.0.0 method summary all methods instance methods abstract methods modifier and type method and description void onconnected() called when a connection to the health data store has been established. void onconnectionfailed(healthconnectionerrorresult error) called when a connection to the health data store has failed. void ondisconnected() called when a connection to the health data store has been lost. method detail onconnected void onconnected() called when a connection to the health data store has been established. it is invoked after creating a healthdatastore instance. since: 1.0.0 onconnectionfailed void onconnectionfailed(healthconnectionerrorresult error) called when a connection to the health data store has failed. note that it is invoked after creating a healthdatastore instance. since: 1.0.0 ondisconnected void ondisconnected() called when a connection to the health data store has been lost. note that it is not invoked caused by healthdatastore.disconnectservice(). it is only invoked if the health data service crashes. since: 1.0.0

      https://developer.samsung.com/health/android/data/api-reference/com/samsung/android/sdk/healthdata/HealthDataStore.ConnectionListener.html
      1. Develop
      2. Health

      api

      HealthDataResolver.UpdateRequest.Builder

      overview package class tree deprecated index com.samsung.android.sdk.healthdata class healthdataresolver.updaterequest.builder java.lang.object com.samsung.android.sdk.healthdata.healthdataresolver.updaterequest.builder enclosing interface: healthdataresolver.updaterequest public static class healthdataresolver.updaterequest.builder extends object this class is a builder to configure healthdataresolver.updaterequest. only inserted health data by your application can be updated. the following example shows how to update calrories of existing health data. public class healthdataresolverexample { private healthdataresolver.updaterequest buildupdaterequest() { healthdevice mydevice = new healthdevicemanager(mstore).getlocaldevice(); healthdata data = new healthdata(); data.setsourcedevice(mydevice.getuuid()); data.putfloat(healthconstants.nutrition.calorie, 100); healthdataresolver.filter filter = healthdataresolver.filter.eq(healthconstants.nutrition.calorie, 10000); // build a request to update nutrition data which its calories is 10000 to 100 healthdataresolver.updaterequest request = new healthdataresolver.updaterequest.builder() .setdatatype(healthconstants.nutrition.health_data_type) .setfilter(filter) .sethealthdata(data) .build(); return request; } } since: 1.0.0 constructor summary constructors constructor and description builder() helps to construct a healthdataresolver.updaterequest object. method summary all methods instance methods concrete methods modifier and type method and description healthdataresolver.updaterequest build() builds a new healthdataresolver.updaterequest object. healthdataresolver.updaterequest.builder setdatatype(string type) sets a health data type to update. healthdataresolver.updaterequest.builder setfilter(healthdataresolver.filter filter) sets a filter for health data to update. healthdataresolver.updaterequest.builder sethealthdata(healthdata object) sets a health data object to update. healthdataresolver.updaterequest.builder setlocaltimerange(string timeproperty, string offsetproperty, long begin, long end) sets the local time range not to miss data from the query's result when there exist data with a different time_offset in the saved health data. healthdataresolver.updaterequest.builder setsourcedevices(list<string> uuidlist) sets a uuid list of source devices for health data to be updated. constructor detail builder public builder() helps to construct a healthdataresolver.updaterequest object. since: 1.0.0 method detail setdatatype public healthdataresolver.updaterequest.builder setdatatype(string type) sets a health data type to update. it has to be specified before calling build(). parameters: type - health_data_type of the data type returns: the object that applies the health data type since: 1.0.0 sethealthdata public healthdataresolver.updaterequest.builder sethealthdata(healthdata object) sets a health data object to update. it has to be specified before calling build(). parameters: object - the health data object to update. the source device of object should be valid. returns: the object that applies health data to update since: 1.0.0 setfilter public healthdataresolver.updaterequest.builder setfilter(healthdataresolver.filter filter) sets a filter for health data to update. parameters: filter - the filter object to update returns: the object that applies the filter since: 1.0.0 setsourcedevices public healthdataresolver.updaterequest.builder setsourcedevices(list<string> uuidlist) sets a uuid list of source devices for health data to be updated. parameters: uuidlist - the uuid list for source devices returns: the object that applies source devices since: 1.0.0 setlocaltimerange public healthdataresolver.updaterequest.builder setlocaltimerange(string timeproperty, string offsetproperty, long begin, long end) sets the local time range not to miss data from the query's result when there exist data with a different time_offset in the saved health data. the data that has a different time_offset with other data's time_offset can be saved when the daylight time is applied or the user moves to another region by like a travel. building a complete query to aggregate all data including the different time_offset is not easy. use this api to build an aggregate request as possible. parameters: timeproperty - the time property name that needs to add a filter offsetproperty - the time offset property begin - the beginning time with gmt+0 milliseconds. e.g. if you would like to update data from 00:00:00 on october 26th, 2021 in your region, set the value with 1635206400000. see sample codes. its minimum value is long.min_value. end - the end time with gmt+0 milliseconds. e.g. if you would like to update data until 00:00:00 on october 26th, 2021 in your region, set the value with 1635206400000. see sample codes. its maximum value is long.max_value. returns: the object that applies the local time range since: 1.5.0 build public healthdataresolver.updaterequest build() builds a new healthdataresolver.updaterequest object. check if following information is specified. data type health data to update returns: the healthdataresolver.updaterequest object throws: illegalstateexception - if data type, or health data object is not specified since: 1.0.0 see also: setdatatype(string), sethealthdata(healthdata)

      https://developer.samsung.com/health/android/data/api-reference/com/samsung/android/sdk/healthdata/HealthDataResolver.UpdateRequest.Builder.html
      No Search Results
      No Search results. Try using another keyword.
      • <<
      • <
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • >
      • >>
      Samsung Developers
      Samsung Developers
      Quick Link
      • Android USB Driver
      • Code Lab
      • Galaxy Emulator Skin
      • Foldables and Large Screens
      • One UI Beta
      • Remote Test Lab
      • Samsung Developers Podcast
      Family Site
      • Bixby
      • Knox
      • Samsung Pay
      • SmartThings
      • Tizen
      • Samsung Research
      • Samsung Open Source
      • Samsung Dev Spain
      • Samsung Dev Brazil
      Legal
      • Terms
      • Privacy
      • Open Source License
      • Cookie Policy
      Social Communications
      • Facebook
      • Instagram
      • Twitter
      • YouTube
      • Buzzsprout
      • Rss
      • Linkedin
      • System Status
      • Site Map
      • System Status
      • Site Map
      • facebook
      • instagram
      • twitter
      • youtube
      • buzzsprout
      • rss
      • linkedin

      Copyright © 2023 SAMSUNG. All rights reserved.