• 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
      • Galaxy Watch for Tizen
      • Watch Face Studio
      • One UI Watch for Tizen
      • Galaxy Watch Studio Converter
      • Samsung IAP for Galaxy Watch (Tizen)
    • 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
    • SDC23
    • 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 (100)
      • SDK
      • API REFERENCE
      • CODE LAB
      • BLOG
      • NEWS/EVENTS
      • OTHERS
        api reference code lab blog news/events
      1. Develop
      2. Health

      doc

      Release Note

      release note introduction release date: september 26, 2019 release contents health device specs ble compatible guidelines for following health devices:blood glucose meterblood pressure monitorheart rate monitorweight scalesamsung health specifications for following health devices:exercise monitorenhanced heart rate monitorpedometersleep monitorsamsung health specification for multiple health service devices:handling multiple data typessetting user info verification tool it checks overall implementation of your health device for whole samsung health’s device specs. change history sep 26, 2019 [update] tools testapps_weight.apk and verificationtool.apk are updated. a pop-up displays for a device’s location access if it is not enabled. april 11, 2019 [new feature] weight scale user data service is defined for a multiple user scenario. see its spec 2.0. [update] tools testapps_weight.apk and verificationtool.apk are updated as a weight scale spec update. nov 23, 2017 the following tools to test your health device are added. test apps verification tool oct 17, 2017 samsung health device sdk v1.0.0 a new sdk release

      https://developer.samsung.com/health/device/release-note.html
      1. Develop
      2. Health

      doc

      Developer Mode

      developer mode a partner app can connect with samsung health if its package name and signature (sha256) are same with the registered info in samsung health. the registered app signature is from the partner app's release key. but in many cases, developers use a different app signing key to test or debug the app. to make it easy, samsung health provides a developer mode. the developer mode is not activated by default. activating the developer mode requires an access key from samsung health 6.11. the access key is shared by samsung health team after a partnership approval. how to activate the developer mode you can activate it with the following steps: select the action overflow of samsung health on the top-left. select the settings icon in the action list's top-right. select about samsung health. tap the version line region quickly 10 times or more. the exact region to tap is illustrated with the blue box in the figure below. if it succeeds, a developer mode button displays. select the developer mode button and enter the developer mode page. enter your app package name and access code that samsung health team shared and select the add button. the access code is case-sensitive. if it succeeds, your app package name will be listed up below. it means the developer mode is activated for your app. back to about samsung health with the back button on the top-left and select the info icon on the top-right. now you can test your app with samsung health. if your app package name is not added well please check the entered app package name and access code carefully. they should be matched exactly. a failure can be from entering: a different app package name unmatched case for an access key how long will be maintained the added app's developer mode in the developer mode page is valid until uninstalling samsung health. and it doesn't work for another app that has a different app package name. if samsung health is reinstalled, enter your app package name and its access code. if you remove your app from the developer mode page by selecting the "-" icon, the developer mode will be deactivated for your app.

      https://developer.samsung.com/health/android/data/guide/dev-mode.html
      1. Develop
      2. Health

      doc

      Verification Tool

      verification tool verification tool download | sep 26, 2019 (211.32 kb) the verification tool of samsung health sdk for device enables you to check the whole sdk specifications on your health device. you can check a verification result with the verification tool and fix your implementation on the health device. prerequisites verification tool downloads the verification tool and install it on an android phone. it runs on android 6.0 marshmallow (api level 23) or above. ble health device turn on the phone’s bluetooth. turn on your ble health device that follows samsung health device specs. how to use verification tool 1. run the verification tool and select one of health devices in the list. 2. allow the location permission. 3. tap start scan button. 4. select your ble health device. if it is not shown up, check the phone’s bluetooth state or your ble health device. 5. select ok. 6. after few seconds, the test is started automatically. select ok. 7. follow a test guide. measure the blood pressure in your ble health device to send the data to the paired phone. the sending time or method can be different for the health device model. select ok after sending the measured data to the phone. 8. this test guide is shown after finishing the test. 9. a test result is shown. 10. select the top-right more menu and save to file for the test result. the saved file’s location is in android/data/shealth.devicesdk. restart helps a re-test without scanning and pairing steps.

      https://developer.samsung.com/health/device/verification-tool.html
      1. Develop
      2. Health

      doc

      Privacy

      privacy privacy is a key for handling health data. samsung health sdk for android enables your application to access health data based on the user's consent. permission manager the sdk's supported data types except health document need to gain permission through permissionmanager. an application needs to declare proper permissions for handling required health data types and to consider secureexception when the application didn't gain a user consent. the user can withdraw consent at any time. see permissionmanager for permission declaration and request. samsung health add the partner app's permission info under samsung health > settings > data permissions > [partner app] after a success of healthpermissionmanager.requestpermission() in the partner app. on the other hand, the partner app needs to make a permission setting menu separately. in the menu, the app calls healthpermissionmanager.requestpermission() with required permissions. the samsung health's health data framework pops up the permission ui. a permission result event is retreived after the user's agreement or denial on the permission popup. the app should provide an interface that the user may change data permission at any time. the user consent is limited to the device. even if multiple devices use the same samsung account, the application has to acquire the user consent on each device independently. instant permission a very sensitive data type like a health document requires gaining instant permission. instant permission is created for one-time data access. an app that handles a health document has to call the instant permission api whenever it needs to access data. related apis are: healthdataresolver.insertwithpermission() healthdataresolver.readwithpermission() healthdataresolver.deletewithpermission()

      https://developer.samsung.com/health/android/data/guide/privacy.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

      doc

      Release Note

      release note introduction release date: nov 3, 2020 release contents content description libraries libraries to sync health data with samsung health sample sample app codes with simplehealth, stepdiary, and foodnote tool dataviewer to test a created app documents api reference, programming guide change history jan 14, 2021 service package removal from samsung health v6.15, the service package doesn't work. the data library is not changed. nov 3, 2020 data 1.5.0 [changes] data library the data library is provided with 'aar' from 1.5.0. compatible samsung health version samsung health 6.12 or above works with the data package 1.5.0. data types "com.samsung.shealth.step_daily_trend" is defined with a new interface. use healthconstants.stepdailytrend instead of it. the new interface doesn't affect to existing apps that use "com.samsung.shealth.step_daily_trend". vo2_max is added to healthconstants.exercise. data viewer tool removing electrocardiogram and healthdocument from a data type list. [deprecation] healthconstants.electrocardiogram is deprecated. august 7, 2020 [changes] developer mode from samsung health 6.11, the developer mode needs a dev access key. see developer mode guide. data viewer tool dataviewer is updated with reading data only. stepdiary sample app it is provided with kotlin. june 22, 2020 service package - deprecated the service package is deprecated. do not use this feature any more. nov 28, 2019 service 1.4.0 [android 10 support] in samsung health 6.8, trackermanager.startactivity() is updated for android 10 to work well even samsung health is on the background. [deprecation] the following trackers are deprecated in trackermanager.trackerid. spo2 thermo_hygrometer uv apr 11, 2019 data 1.4.0 [important notice] data 1.4.0 library includes important changes. all partner app must use this version until july 2019. otherwise, your app will do not work with samsung health properly. it supports security enhancements in android 8.0. applications that target android 9 or higher cannot share data with other applications using socket. it works with samsung health 6.2 or above. healthconnectionerrorresult.old_version_platform must be handled to install the latest samsung health. update your app by applying all changes below to make a seamless service. [new] healthconstants.nutrition a nutrition data type is added. replace healthconstants.foodinfo & healthconstants.foodintake to healthconstants.nutrition. they will be removed in the next release. [deprecation & behavior changes] healthdataservice is deprecated. call just healthdatastore.connectservice() without after calling healthdataservice.initialize(). remove sdk-v1.0.0.jar. healthuserprofile’s some apis are deprecated and have a behavior change. getuserid() is not valid anymore. its behavior is changed to return an empty string for privacy policy enhancement. it will be removed in the next release. getimage() is not valid anymore. its behavior is changed to return null for privacy policy enhancement. it will be removed in the next release. healthdataresolver's inserting and updating data apis have a behavior change: `healthdataresolver.insert()` <br> `healthdataresolver.update()` <br> `healthdataresolver.insertwithpermission()` - `illegalargumentexception` is returned only if the request contains invalid instance type. - check the result with `getstatus()` of `healthresultholder.baseresult`. a data validation error is received as `status_invalid_input_data` in `healthresultholder.resultlistener.onresult()`. the data validation includes missing mandatory fields, wrong field type, out of the data value range and oversized blob. - see its [example](https://img-developer.samsung.com/onlinedocs/health/android/data/com/samsung/android/sdk/healthdata/healthdataresolver.insertrequest.html). [sample & tool update] sample apps foodnote is updated as replacing healthconstants. healthconstants.foodinfo and healthconstants.foodintake to healthconstants.nutrition. stepdiary's typo is fixed. dataviewer a data type list is updated with healthconstants.nutrition. healthconstants.foodinfo and healthconstants.foodintake is dropped out. sep 13, 2018 service 1.3.1 trackermanager.destination reward destination is deprecated. it goes to an error page from samsung health 6.0. trackertile setting date and content color in a tracker tile is not available from samsung health 6.0. setdate() is deprecated. setcontentcolor() is deprecated. tracker design guide is updated. may 25, 2018 data 1.3.0 daily step count trend ("com.samsung.shealth.step_daily_trend") "1" and "2" source type values that indicate wearable and activity trackers are deprecated. see deprecated info here. the data library is same. jan 11, 2018 data 1.3.0 healthconstants.foodinfo deprecated as he data library is same. do not use it any more. it will be removed. healthconstants.foodintake food_info_id is deprecated. oct 26, 2017 service 1.3.0 trackermanager.trackerid added. the existing fields for samsung health's trackers are deprecated. use the new class fields. jumping to a tracker's specific destination like trends is available. trackermanager.destination added. a new startactivity() api that has a destination param is added to trackermanager. sample app is updated to sampleservice. for more detailed information, refer to here. oct 17, 2017 the sdk name became "samsung health android sdk". aug 24, 2017 dataviewer tool is updated. a minor defect is patched. jul 27, 2017 data 1.3.0 new data types supported data types are added including floors climbed and health document. instant permission instant permission apis to handle health document are added. some properties are added: healthconstants.common: custom healthconstants.exercise: additional, max_rpm healthconstants.heartrate: min, max, binning_data healthconstants.weight: body_fat_mass, fat_free, fat_free_mass, skeletal_muscle_mass, total_body_water healthdata apis to handle inputstream are added. setlocaltimerange() is added to handle the local time zone change easily. healthdataresolver.aggregaterequest.builder healthdataresolver.readrequest.builder iterator() and close() are added to healthdataresolver.aggregateresult. more health data units are added. healthdatautil class is added. a new sample app stepdiary is added. the dataviewer tool is updated. more supported data types are added. the user interfaces are improved. for more detailed information, refer to here. apr 27, 2017 some terms are changed: "s health" app name is rebranded to "samsung health". "samsung health sdk" is used for the sdk’s name instead of "samsung digital health sdk". only the library names are changed according to the sdk naming. you don’t need to update your app. sample apps are updated by the changed terms. related documents are updated by the changed terms. jun 23, 2016 service 1.2.0 apis for the feature availability check are added in the shealth class. feature_tracker_launch feature_tracker_tile isfeatureenabled(int...) shealth.isfeatureenabled(int) was the default implementation and didn't work. it is updated to check the feature availability. to launch the s health’s specific tracker with trackerinfo and trackermanager, s health 4.8 or above is needed. feb 25, 2016 data 1.2.1 a new meal type, meal_type_before_sleep is added to healthconstants.bloodglucose. mean_rpm is added to healthconstants.exercise. in 1.2.0, healthconnectionerrorresult.unknown had been retrieved when s health prior to 4.6 is installed on the device. in this release, a bug for the wrong error value is fixed to give healthconnectionerrorresult.old_version_platform. you can solve the error situation by calling healthconnectionerrorresult.resolve(). the following apis are deprecated: healthresultholder.cancel() healthresultholder.baseresult.status_canceled nov 26, 2015 data 1.2.0 healthdevapp is removed. use dataviewer to test your application. "com.samsung.android.health.platform_type" in manifest to use healthdevapp is not required. to make a clear operation after the permission ui is popped up, the existing permissionmanager.requestpermissions() is deprecated. use new api with the activity parameter instead of it. connectservice() with the timeout parameter is added to healthdatastore. healthconstants.sleepstage to present detailed sleep data is added. body fat, skeletal muscle, muscle mass, and basal metabolic rate properties are added to healthconstants.weight. the minimum heart rate property is added to healthconstants.exercise. the user name and user’s picture image can be retrieved through healthuserprofile. for more detailed information, refer to here. service 1.1.0 s health simulator is removed from the sdk tool because s health’s available devices had been expanded. shealth.initialize() doesn’t throw ssdkunsupportedexception and securityexception. com.samsung.android.providers.context.permission.write_use_app_feature_survey permission is not required. the title of tile design guidelines is changed to tracker design guidelines. jun 18, 2015 data 1.1.0 sample application projects are updated to import them on android studio. healthconnectionerrorresult the device that supports s health 4.x can be checked with hasresolution(). hasresolution() and resolve() require the android.permission.internet permission. healthconstants.bloodglucose meal_type before_meal and meal_type general are added. meal_type_after_bedtime is deprecated. "treadmill" and "elliptical trainer" are added to the predefined type of healthconstants.exercise. putnull() to set a value of data property as null is added to healthdata. available ranges or operations of some apis are changed. for more detailed information, refer to here. mar 31, 2015 data 1.0.0 healthconnectionerrorresult.resolve()'s operation is changed without a dialog. some constants for unit are added and descriptions of healthconstants interfaces are changed. if the handler parameter of the healthdataobserver’s constructor is null, the looper of the current thread will be used for the callback. a permissible range of medical data for countries is expanded. for more detailed information, refer to here. service 1.0.0 guide for trackereventlistener is supplemented. check your application after referring to the api reference and programming guide. description of tile design guideline for tracker is supplemented. the icon size of tracker_tile_type_1 is changed to 60. known issues none features health data store handles the service connection. inserts, reads, updates and deletes health data. health data type predefined data types such as counting steps or nutrition. data permission checks and requests permissions to handle health data.

      https://developer.samsung.com/health/android/release-note.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
      1. Develop
      2. Health

      api

      HealthDataResolver.ReadRequest.Builder

      overview package class tree deprecated index com.samsung.android.sdk.healthdata class healthdataresolver.readrequest.builder java.lang.object com.samsung.android.sdk.healthdata.healthdataresolver.readrequest.builder enclosing interface: healthdataresolver.readrequest public static class healthdataresolver.readrequest.builder extends object this class is a builder to configure healthdataresolver.readrequest. private healthdataresolver.readrequest buildreadrequest(long starttime, long endtime) { healthdataresolver.filter filter = healthdataresolver.filter.greaterthan(healthconstants.nutrition.calorie, 200); healthdataresolver.readrequest request = new healthdataresolver.readrequest.builder() .setdatatype(healthconstants.nutrition.health_data_type) .setlocaltimerange(healthconstants.nutrition.start_time, healthconstants.nutrition.time_offset, starttime, endtime) .setfilter(filter) .build(); return request; } since: 1.0.0 constructor summary constructors constructor and description builder() helps to construct a healthdataresolver.readrequest object. method summary all methods instance methods concrete methods modifier and type method and description healthdataresolver.readrequest build() builds a new healthdataresolver.readrequest object. healthdataresolver.readrequest.builder setdatatype(string type) sets a health data type for the request to read. healthdataresolver.readrequest.builder setfilter(healthdataresolver.filter filter) sets a filter for the request to read. healthdataresolver.readrequest.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.readrequest.builder setpackagename(string packagename) sets the package name that provides health data to read. healthdataresolver.readrequest.builder setproperties(string[] properties) sets a property array for the health data result to read. healthdataresolver.readrequest.builder setpropertyalias(string property, string alias) sets an alias for the given property. healthdataresolver.readrequest.builder setresultcount(int offset, int count) sets the count range of result data with a given offset and count. healthdataresolver.readrequest.builder setsort(string property, healthdataresolver.sortorder sortorder) sets the sort order for a given property or alias. healthdataresolver.readrequest.builder setsourcedevices(list<string> uuidlist) sets a uuid list for source devices to read health data. healthdataresolver.readrequest.builder settimeafter(long time) sets the time range to retrieve result data which is inserted or updated to the health data store after the given time. constructor detail builder public builder() helps to construct a healthdataresolver.readrequest object. since: 1.0.0 method detail setdatatype public healthdataresolver.readrequest.builder setdatatype(string type) sets a health data type for the request to read. 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 setfilter public healthdataresolver.readrequest.builder setfilter(healthdataresolver.filter filter) sets a filter for the request to read. parameters: filter - the filter object returns: the object that applies the filter since: 1.0.0 setsourcedevices public healthdataresolver.readrequest.builder setsourcedevices(list<string> uuidlist) sets a uuid list for source devices to read health data. parameters: uuidlist - the uuid list for source devices returns: the object that applies source devices since: 1.0.0 setproperties public healthdataresolver.readrequest.builder setproperties(string[] properties) sets a property array for the health data result to read. if it is not specified, the health data result shows all properties of the data type. parameters: properties - properties that want to gain in the result returns: the object that applies properties since: 1.0.0 setpropertyalias public healthdataresolver.readrequest.builder setpropertyalias(string property, string alias) sets an alias for the given property. parameters: property - the property to be shown with the alias alias - the alias for the property returns: the object that applies the alias for the property since: 1.0.0 setpackagename public healthdataresolver.readrequest.builder setpackagename(string packagename) sets the package name that provides health data to read. accessory data's package name samsung health collects the linked accessory's data also like galaxy watch. the accessory's data including galaxy watch is inserted to samsung health with the samsung health's package name, com.sec.android.app.shealth. if you want to read only the specific accessory's data, make a division the device id. parameters: packagename - the package name that provides health data returns: the object that applies the package name since: 1.0.0 setsort public healthdataresolver.readrequest.builder setsort(string property, healthdataresolver.sortorder sortorder) sets the sort order for a given property or alias. parameters: property - the property or alias to be shown with the sort order sortorder - the sort order returns: the object that applies the sort order since: 1.0.0 setresultcount public healthdataresolver.readrequest.builder setresultcount(int offset, int count) sets the count range of result data with a given offset and count. if this method is not called, all result will be obtained from the result. if you want to get only 10 data from the 3rd position in the result, set offset as 2 and count as 10. parameters: offset - the start position in the whole result, which equals to or is greater than 0 count - the limited count of result, which is greater than 0 returns: the object that applies the range of the result since: 1.0.0 settimeafter public healthdataresolver.readrequest.builder settimeafter(long time) sets the time range to retrieve result data which is inserted or updated to the health data store after the given time. it's different to set the time range based on the data's created or updated time to read data. if then, use: healthdataresolver.filter.greaterthan(java.lang.string, t) moreover it is useful to check the health data store's change after your app reads the health data store's data at the last time. if the data's source device is same with the current device, time means the inserted time that data is created on the current device. if the data's source device is different, time indicates the synchronized time that data on other devices is synchronized to samsung health of the current device. parameters: time - the time range to retrieve result data which is inserted or updated to the health data store after the specific time in milliseconds. its value is started from january, 1, 1970 00:00:00 utc. returns: the object that applies the range of the result since: 1.0.0 setlocaltimerange public healthdataresolver.readrequest.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 read all data including the different time_offset is not easy. use this api to build a read 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 get 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 get 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.3.0 build public healthdataresolver.readrequest build() builds a new healthdataresolver.readrequest object. check if following information is specified. data type returns: the healthdataresolver.readrequest object throws: illegalstateexception - if enough information is not specified since: 1.0.0 see also: setdatatype(string)

      https://developer.samsung.com/health/android/data/api-reference/com/samsung/android/sdk/healthdata/HealthDataResolver.ReadRequest.Builder.html
      1. Learn
      2. Code Lab

      codelab

      Measure Blood Oxygen Level on Galaxy Watch

      measure blood oxygen level on galaxy watch objective create a health app for galaxy watch, operating on wear os powered by samsung, utilizing the new samsung privileged health sdk to trigger and obtain blood oxygen level (spo2) measurement results. partnership request in this code lab, you will use a specially prepared mock library. it has limited functionality and uses dummy data instead of real-time data. to get real values, you will need the full version of the samsung privileged health sdk library, which is available to registered samsung partners. apply as a partner by checking out the partner app program to get exclusive access to the samsung privileged health sdk. overview samsung privileged health sdk provides means of accessing and tracking health information contained in the health data storage. its tracking service gives raw and processed sensor data such as accelerometer and body composition data sent by the samsung bioactive sensor. the latest bioactive sensor of galaxy watch runs powerful health sensors such as photoplethysmogram (ppg), electrocardiogram (ecg), bioelectrical impedance analysis (bia), sweat loss, and spo2. see samsung privileged health sdk descriptions for detailed information. set up your environment you will need the following: galaxy watch4 or newer android studio (latest version recommended) java se development kit (jdk) 11 or later sample code here is a sample code for you to start coding in this code lab. download it and start your learning experience! measuring blood oxygen level sample code (110.13 kb) turn on developer mode and adjust its settings on your watch, go to settings > about watch > software and tap on software version 5 times. upon successful activation of developer mode, a toast message will display as on the image below. afterwards, developer options will be visible under settings. tap developer options and enable the following options: adb debugging debug over wi-fi turn off automatic wi-fi connect your galaxy watch to wi-fi go to settings > connection > wi-fi and make sure that wi-fi is enabled. from the list of available wi-fi networks, choose and connect to the same one as your pc. when successfully connected, tap a wi-fi network name, swipe down, and note the ip address. you will need this to connect your watch over adb from your pc. connect your galaxy watch to android studio in android studio, go to terminal and type: adb connect <ip address as mentioned in previous step> when prompted, tap always allow from this computer to allow debugging. upon successful connection, you will see the following message in android studio’s terminal: connected to <ip address of your watch> now, you can run the app directly on your watch. start your project after downloading the sample code containing the project files, in android studio click open to open existing project. locate the downloaded android project (basic) from the directory and click ok. check capabilities for the device to track data with the samsung privileged health sdk, it must support a given tracker type – blood oxygen level. to check this, get the list of available tracker types and verify that the tracker is on the list. in the connectionmanager.java file, navigate to the isspo2available() function, use a provided healthtrackingservice object to create a healthtrackercapability instance, send it to the checkavailabletrackers function, and assign its result to the availabletrackers list. gettrackingcapability() returns a healthtrackercapability instance in the healthtrackingservice object healthtrackingservicehealthtrackingservice initiates a connection to samsung's health tracking service and provides a healthtracker instance to track a healthtrackertype. public healthtrackercapability gettrackingcapability() provide a healthtrackercapability instance to get a supporting health tracker type list. /****************************************************************************************** * [practice 1] check capabilities to confirm spo2 availability * * ---------------------------------------------------------------------------------------- * * (hint) replace todo 1 with java code * get healthtrackercapability object from healthtrackingservice * send the object to checkavailabletrackers() ******************************************************************************************/ public boolean isspo2available(healthtrackingservice healthtrackingservice) { if (healthtrackingservice == null) return false; list<healthtrackertype> availabletrackers = null; //"todo 1" if (availabletrackers == null) return false; else return availabletrackers.contains(healthtrackertype.spo2); } check connection error resolution suppose a connection to the health tracking service attempt ends with an error. in that case, you can try to resolve it using the samsung privileged health sdk api. in the connectionmanager.java file, navigate to the processtrackerexception() function, and check if the provided healthtrackerexception object has a resolution. assign the result to hasresolution variable. hasresolution() function in the healthtrackerexception object checks if the api side can fix the error healthtrackerexceptionhealthtrackerexception contains error codes and checks the error's resolution. if there is a resolution, solving the error is available by calling resolve(activity). boolean hasresolution() checks whether the given error has a resolution. /******************************************************************************************* * [practice 2] resolve healthtrackerexception error * * ----------------------------------------------------------------------------------------- * * (hint) replace todo 2 with java code * call hasresolution() on healthtrackerexception object ******************************************************************************************/ public void processtrackerexception(healthtrackerexception e) { boolean hasresolution = false; //"todo 2" if (hasresolution) e.resolve(callingactivity); if (e.geterrorcode() == healthtrackerexception.old_platform_version || e.geterrorcode() == healthtrackerexception.package_not_installed) observerupdater.getobserverupdater().notifyconnectionobservers(r.string.novalidhealthplatform); else observerupdater.getobserverupdater().notifyconnectionobservers(r.string.connectionerror); log.e(tag, "could not connect to health tracking service: " + e.getmessage()); } initialize spo2 tracker before the measurement starts, initialize the spo2 tracker by obtaining the proper health tracker object. in the spo2listener.java file, navigate to the init() function. using the provided healthtrackingservice object, create an instance of the spo2 tracker and assign it to the spo2tracker object. gethealthtracker() with healthtrackertype.spo2 as an argument will create a healthtracker instance healthtrackingservicehealthtrackingservice initiates a connection to samsung's health tracking service and provides a healthtracker instance to track a healthtrackertype. healthtracker gethealthtracker(healthtrackertype healthtrackertype) provides a healthtracker instance for the given healthtrackertype. /******************************************************************************************* * [practice 3] initialize spo2 tracker * * ---------------------------------------------------------------------------------------- * * (hint) replace todo 3 with java code * initialize spo2tracker with proper samsung privileged health sdk functionality * call gethealthtracker() on healthtrackingservice object * use healthtrackertype.spo2 as an argument ******************************************************************************************/ void init(healthtrackingservice healthtrackingservice) { //"todo 3" } perform measurement for the client app to start obtaining the data through the sdk, it has to set a listener method on the healthtracker. the application setups the listener when the user taps on the measure button. each time there is new data, the listener callback receives it. after the measurement completes, the listener has to be disconnected. since, due to battery drain, on-demand measurement should not last more than approximately 30 seconds. the measurement will cancel if the final blood oxygen level value is not delivered in time. it’s also worth noting that the sensor needs a few seconds to warm up and provide correct values, adding to the overall measurement time. the blood oxygen level values come in the ondatareceived callback of trackereventlistener. see below example of the code, in the spo2listener.java file, reading the value: private final healthtracker.trackereventlistener spo2listener = new healthtracker.trackereventlistener() { @override public void ondatareceived(@nonnull list<datapoint> list) { for (datapoint data : list) { updatespo2(data); } } }; private void updatespo2(datapoint data) { int status = data.getvalue(valuekey.spo2set.status); int spo2value = 0; if (status == measurement_completed) spo2value = data.getvalue(valuekey.spo2set.spo2); observerupdater.getobserverupdater().notifytrackerobservers(status, spo2value); } run unit tests for your convenience, you will find an additional unit tests package. this will let you verify your code changes even without using a physical watch. see instructions below on how to run the unit tests: right click on com.samsung.sdc22.health.basic (test) and execute run 'tests in 'com.samsung.sdc22.health.basic'' command. if you completed all the tasks correctly, you will see all the unit tests passed successfully. run the app after building the apk, you can run the application on a connected device to measure your blood oxygen level. right after the app is started, it will request user permission. allow the app to receive data from the body sensors. afterwards, it will show the application's main screen. to get the blood oxygen level value, tap on the measure button. to stop the measurement, tap on the stop button. you're done! congratulations! you have successfully achieved the goal of this code lab. now, you can create a health app that measures blood oxygen level by yourself! if you're having trouble, you may download this file: measuring blood oxygen level complete code (109.86 kb) to learn more about samsung health, visit: developer.samsung.com/health

      https://developer.samsung.com/codelab/health/blood-oxygen.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
      • SamsungOpen 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.