Filter
-
Content Type
-
Category
Mobile/Wearable
Visual Display
Digital Appliance
Platform
Recommendations
Filter
tutorials health, galaxy watch, mobile
blogthe samsung privileged health sdk enables your application to collect vital signs and other health parameters tracked on galaxy watch running wear os powered by samsung. the tracked data can be displayed immediately or retained for later analysis. some kinds of tracked data, such as batching data, are impractical to display on a watch screen in real-time, so it is common to store the data in a database or server solution or show them on the larger screen of a mobile device. this blog demonstrates how to develop 2 connected sample applications. a watch application uses the samsung privileged health sdk to collect heart rate tracker data, then uses the wearable data layer api to transmit it to a companion application on the user’s android mobile device, which displays the data as a simple list on its screen. you can follow along with the demonstration by downloading the sample application project. to test the applications, you need a galaxy watch4 (or higher model) and a connected android mobile device. creating the application project the application project consists of a wearable module for the watch, and a mobile module for android mobile devices: in android studio, select open file > new > new project. select wear os > empty wear app and click next. new wear app define the project details. project details to create a companion mobile application for the watch application, check the pair with empty phone app box. notemake sure that the application id is identical for both modules in their “build.gradle” files. for more information about creating multi-module projects, see from wrist to hand: develop a companion app for your wearable application. implementing the watch application the watch application ui has 2 buttons. the start/stop button controls heart data tracking, and the send button transfers the collected data to the connected mobile device. the screen consists of a heart rate field and 4 ibi value fields, since there can be up to 4 ibi values in a single tracking result. watch application ui track and extract heart rate data when the user taps the start button on the wearable application ui, the starttracking() function from the mainviewmodel class is invoked. the application must check that the galaxy watch supports the heart rate tracking capability that we want to implement, as the supported capabilities depend on the device model and software version. retrieve the list of supported health trackers with the trackingcapability.supporthealthtrackertypes of the healthtrackingservice class: override fun hascapabilities(): boolean { log.i(tag, "hascapabilities()") healthtrackingservice = healthtrackingserviceconnection.gethealthtrackingservice() val trackers: list<healthtrackertype> = healthtrackingservice!!.trackingcapability.supporthealthtrackertypes return trackers.contains(trackingtype) } to track the heart rate values on the watch, read the flow of values received in the ondatareceived() listener: @experimentalcoroutinesapi override suspend fun track(): flow<trackermessage> = callbackflow { val updatelistener = object : healthtracker.trackereventlistener { override fun ondatareceived(datapoints: mutablelist<datapoint>) { for (datapoint in datapoints) { var trackeddata: trackeddata? = null val hrvalue = datapoint.getvalue(valuekey.heartrateset.heart_rate) val hrstatus = datapoint.getvalue(valuekey.heartrateset.heart_rate_status) if (ishrvalid(hrstatus)) { trackeddata = trackeddata() trackeddata.hr = hrvalue log.i(tag, "valid hr: $hrvalue") } else { coroutinescope.runcatching { trysendblocking(trackermessage.trackerwarningmessage(geterror(hrstatus.tostring()))) } } val validibilist = getvalidibilist(datapoint) if (validibilist.size > 0) { if (trackeddata == null) trackeddata = trackeddata() trackeddata.ibi.addall(validibilist) } if ((ishrvalid(hrstatus) || validibilist.size > 0) && trackeddata != null) { coroutinescope.runcatching { trysendblocking(trackermessage.datamessage(trackeddata)) } } if (trackeddata != null) { validhrdata.add(trackeddata) } } trimdatalist() } fun geterror(errorkeyfromtracker: string): string { val str = errors.getvalue(errorkeyfromtracker) return context.resources.getstring(str) } override fun onflushcompleted() { log.i(tag, "onflushcompleted()") coroutinescope.runcatching { trysendblocking(trackermessage.flushcompletedmessage) } } override fun onerror(trackererror: healthtracker.trackererror?) { log.i(tag, "onerror()") coroutinescope.runcatching { trysendblocking(trackermessage.trackererrormessage(geterror(trackererror.tostring()))) } } } heartratetracker = healthtrackingservice!!.gethealthtracker(trackingtype) setlistener(updatelistener) awaitclose { log.i(tag, "tracking flow awaitclose()") stoptracking() } } each tracking result is within a list in the datapoints argument of the ondatareceived() update listener. the sample application implements on-demand heart rate tracking, the update listener is invoked every second and each data point list contains 1 element. to extract a heart rate from data point: val hrvalue = datapoint.getvalue(valuekey.heartrateset.heart_rate) val hrstatus = datapoint.getvalue(valuekey.heartrateset.heart_rate_status) a status parameter is returned in addition to the heart rate data. if the heart rate reading was successful, its value is 1. each inter-beat interval data point consists of a list of values and the corresponding status for each value. since samsung privileged health sdk version 1.2.0, there can be up to 4 ibi values in a single data point, depending on the heart rate. if the ibi reading is valid, the value of the status parameter is 0. to extract only ibi data that is valid and whose value is not 0: private fun isibivalid(ibistatus: int, ibivalue: int): boolean { return ibistatus == 0 && ibivalue != 0 } fun getvalidibilist(datapoint: datapoint): arraylist<int> { val ibivalues = datapoint.getvalue(valuekey.heartrateset.ibi_list) val ibistatuses = datapoint.getvalue(valuekey.heartrateset.ibi_status_list) val validibilist = arraylist<int>() for ((i, ibistatus) in ibistatuses.withindex()) { if (isibivalid(ibistatus, ibivalues[i])) { validibilist.add(ibivalues[i]) } } send data to the mobile application the application uses the messageclient class of the wearable data layer api to send messages to the connected mobile device. messages are useful for remote procedure calls (rpc), one-way requests, or in request-or-response communication models. when a message is sent, if the sending and receiving devices are connected, the system queues the message for delivery and returns a successful result code. the successful result code does not necessarily mean that the message was delivered successfully, as the devices can be disconnected before the message is received. to advertise and discover devices on the same network with features that the watch can interact with, use the capabilityclient class of the wearable data layer api. each device on the network is represented as a node that supports various capabilities (features) that an application defines at build time or configures dynamically at runtime. your watch application can search for nodes with a specific capability and interact with it, such as sending messages. this can also work in the opposite direction, with the wearable application advertising the capabilities it supports. when the user taps the send button on the wearable application ui, the sendmessage() function from the mainviewmodel class is invoked, which triggers code in the sendmessageusecase class: override suspend fun sendmessage(message: string, node: node, messagepath: string): boolean { val nodeid = node.id var result = false nodeid.also { id -> messageclient .sendmessage( id, messagepath, message.tobytearray(charset = charset.defaultcharset()) ).apply { addonsuccesslistener { log.i(tag, "sendmessage onsuccesslistener") result = true } addonfailurelistener { log.i(tag, "sendmessage onfailurelistener") result = false } }.await() log.i(tag, "result: $result") return result } } to find a destination node for the message, retrieve all the available capabilities on the network: override suspend fun getcapabilitiesforreachablenodes(): map<node, set<string>> { log.i(tag, "getcapabilities()") val allcapabilities = capabilityclient.getallcapabilities(capabilityclient.filter_reachable).await() return allcapabilities.flatmap { (capability, capabilityinfo) -> capabilityinfo.nodes.map { it to capability } } .groupby( keyselector = { it.first }, valuetransform = { it.second } ) .mapvalues { it.value.toset() } } since the mobile module of the sample application advertises having the “wear” capability, to find an appropriate destination node, retrieve the list of connected nodes that support it: override suspend fun getnodesforcapability( capability: string, allcapabilities: map<node, set<string>> ): set<node> { return allcapabilities.filtervalues { capability in it }.keys } select the first node from the list, encode the message as a json string, and send the message to the node: suspend operator fun invoke(): boolean { val nodes = getcapablenodes() return if (nodes.isnotempty()) { val node = nodes.first() val message = encodemessage(trackingrepository.getvalidhrdata()) messagerepository.sendmessage(message, node, message_path) true } else { log.i(tag, "no compatible nodes found") false } } implementing the mobile application the mobile application ui consists of a list of the heart rate and inter-beat interval values received from the watch. the list is scrollable. mobile application ui receive and display data from the watch application to enable the mobile application to listen for data from the watch and launch when it receives data, define the datalistenerservice service in the mobile application’s androidmanifest.xml file, within the <application> element: <service android:name="com.samsung.health.mobile.data.datalistenerservice" android:exported="true"> <intent-filter> <action android:name="com.google.android.gms.wearable.data_changed" /> <action android:name="com.google.android.gms.wearable.message_received" /> <action android:name="com.google.android.gms.wearable.request_received" /> <action android:name="com.google.android.gms.wearable.capability_changed" /> <action android:name="com.google.android.gms.wearable.channel_event" /> <data android:host="*" android:pathprefix="/msg" android:scheme="wear" /> </intent-filter> </service> implement the datalistenerservice class in the application code to listen for and receive message data. the received json string data is passed as a parameter: private const val tag = "datalistenerservice" private const val message_path = "/msg" class datalistenerservice : wearablelistenerservice() { override fun onmessagereceived(messageevent: messageevent) { super.onmessagereceived(messageevent) val value = messageevent.data.decodetostring() log.i(tag, "onmessagereceived(): $value") when (messageevent.path) { message_path -> { log.i(tag, "service: message (/msg) received: $value") if (value != "") { startactivity( intent(this, mainactivity::class.java) .addflags(intent.flag_activity_new_task).putextra("message", value) ) } else { log.i(tag, "value is an empty string") } } } to decode the message data: fun decodemessage(message: string): list<trackeddata> { return json.decodefromstring(message) } to display the received data on the application screen: @composable fun mainscreen( results: list<trackeddata> ) { column( modifier = modifier .fillmaxsize() .background(color.black), verticalarrangement = arrangement.top, horizontalalignment = alignment.centerhorizontally ) { spacer( modifier .height(70.dp) .fillmaxwidth() .background(color.black) ) listview(results) } } running the applications to run the wearable and mobile applications: connect your galaxy watch and android mobile device (both devices must be paired with each other) to android studio on your computer. select wear from the modules list and the galaxy watch device from the devices list, then click run. the wearable application launches on the watch. connected devices select mobile from the modules list and the android mobile device from the devices list, then click run. the mobile application launches on the mobile device. wear the watch on your wrist and tap start. the watch begins tracking your heart rate. after some tracked values appear on the watch screen, to send the values to the mobile application, tap send. if the mobile application is not running, it is launched. the tracked heart data appears on the mobile application screen. to stop tracking, tap stop on the watch. conclusions the samsung privileged health sdk enables you to track health data, such as heart rate, from a user’s galaxy watch4 or higher smartwatch model. to display the tracked data on a larger screen, you can use the messageclient of the wearable data layer api to send the data to a companion application on the connected mobile device. to develop more advanced application features, you can also use the dataclient class to send data to devices not currently in range of the watch, delivering it only when the device is connected. resources heart rate data transfer code lab
Samsung Developers
tutorials web, galaxy watch
blogthis is part of a 2 hour tizen workshop that you can find here: https://youtu.be/5xp8jfpxom8 in this video, you will learn to use the wearable device sensors and modify a project to detect the user's heart rate. you can also connect with me, diego, a sr. developer evangelist, on twitter: https://twitter.com/hielo777 have questions? post them in our forums: https://forum.developer.samsung.com/ check out other videos, blog posts, and tips to improve your tizen app development. check out the tizen tidbits playlist on our youtube channel, and learn more about the wide selection of samsung technologies on our developer portal.
Diego Lizarazo Rivera
Learn Code Lab
codelabtransfer heart rate data from galaxy watch to a mobile device objective create a health app for galaxy watch, operating on wear os powered by samsung, to measure heart rate and inter-beat interval ibi , send data to a paired android phone, and create an android application for receiving data sent from a paired galaxy watch overview with this code lab, you can measure various health data using samsung health sensor sdk and send it to a paired android mobile device for further processing samsung health sensor sdk tracks various health data, but it cannot save or send collected results meanwhile, wearable data layer allows you to synchronize data from your galaxy watch to an android mobile device using a paired mobile device allows the data to be more organized by taking advantage of a bigger screen and better performance see samsung health sensor sdk descriptions for detailed information set up your environment you will need the following galaxy watch4 or newer android mobile device android studio latest version recommended java se development kit jdk 17 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! heart rate data transfer sample code 213 7 kb connect your galaxy watch to wi-fi go to settings > connection > wi-fi and make sure that the wi-fi is enabled from the list of available wi-fi networks, choose and connect to the same one as your pc 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 in developer options find wireless debugging turn on wireless debugging check always allow on this network and tap allow go back to developer options and click turn off automatic wi-fi notethere may be differences in settings depending on your one ui version connect your galaxy watch to android studio go to settings > developer options > wireless debugging and choose pair new device take note of the wi-fi pairing code, ip address & port in android studio, go to terminal and type adb pair <ip address> <port> <wi-fi pairing code> when prompted, tap always allow from this computer to allow debugging after successfully pairing, type adb connect <ip address of your watch> <port> upon successful connection, you will see the following message in the terminal connected to <ip address of your watch> now, you can run the app directly on your watch turn on developer mode for health platform to use the app, you need to enable developer mode in the health platform on your watch go to settings > apps > health platform quickly tap health platform title for 10 times this enables developer mode and displays [dev mode] below the title to stop using developer mode, quickly tap health platform title for 10 times to disable it set up your android device click on the following links to setup your android device enable developer options run apps on a hardware device connect the galaxy watch with you samsung mobile phone start your project in android studio, click open to open an existing project locate the downloaded android project hrdatatransfer-code-lab from the directory and click ok you should see both devices and applications available in android studio as in the screenshots below initiate heart rate tracking noteyou may refer to this blog post for more detailed analysis of the heart rate tracking using samsung health sensor sdk first, you need to connect to the healthtrackingservice to do that create connectionlistener, create healthtrackingservice object by invoking healthtrackingservice connectionlistener, context invoke healthtrackingservice connectservice when connected to the health tracking service, check the tracking capability the available trackers may vary depending on samsung health sensor sdk, health platform versions or watch hardware version use the gettrackingcapability function of the healthtrackingservice object obtain heart rate tracker object using the function healthtrackingservice gethealthtracker healthtrackertype heart_rate_continuous define event listener healthtracker trackereventlistener, where the heart rate values will be collected start tracking the tracker starts collecting heart rate data when healthtracker seteventlistener updatelistener is invoked, using the event listener collect heart data from the watch the updatelistener collects datapoint instances from the watch, which contains a collection of valuekey objects those objects contain heart rate, ibi values, and ibi statuses there's always one value for heart rate while the number of ibi values vary from 0-4 both ibi value and ibi status lists have the same size go to wear > java > data > com samsung health hrdatatransfer > data under ibidataparsing kt, provide the implementation for the function below /******************************************************************************* * [practice 1] get list of valid inter-beat interval values from a datapoint * - return arraylist<int> of valid ibi values validibilist * - if no ibi value is valid, return an empty arraylist * * var ibivalues is a list representing ibivalues up to 4 * var ibistatuses is a list of their statuses has the same size as ibivalues ------------------------------------------------------------------------------- * - hints * use local function isibivalid status, value to check validity of ibi * ****************************************************************************/ fun getvalidibilist datapoint datapoint arraylist<int> { val ibivalues = datapoint getvalue valuekey heartrateset ibi_list val ibistatuses = datapoint getvalue valuekey heartrateset ibi_status_list val validibilist = arraylist<int> //todo 1 return validibilist } check data sending capabilities for the watch once the heart rate tracker can collect data, set up the wearable data layer so it can send data to a paired android mobile device wearable data layer api provides data synchronization between wear os and android devices noteto know more about wearable data layer api, go here to determine if a remote mobile device is available, the wearable data layer api uses concept of capabilities not to be confused with samsung health sensor sdk’s tracking capabilities, providing information about available tracker types using the wearable data layer's capabilityclient, you can get information about nodes remote devices being able to consume messages from the watch go to wear > java > com samsung health hrdatatransfer > data in capabilityrepositoryimpl kt, and fill in the function below the purpose of this part is to filter all capabilities represented by allcapabilities argument by capability argument and return the set of nodes set<node> having this capability later on, we need those nodes to send the message to them /************************************************************************************** * [practice 2] check capabilities for reachable remote nodes devices * - return a set of node objects out of all capabilities represented by 2nd function * argument, having the capability represented by 1st function argument * - return empty set if no node has the capability -------------------------------------------------------------------------------------- * - hints * you might want to use filtervalues function on the given allcapabilities map * ***********************************************************************************/ override suspend fun getnodesforcapability capability string, allcapabilities map<node, set<string>> set<node> { //todo 2 } encode message for the watch before sending the results of the heart rate and ibi to the paired mobile device, you need to encode the message into a string for sending data to the paired mobile device we are using wearable data layer api’s messageclient object and its function sendmessage string nodeid, string path, byte[] message go to wear > java > com samsung health hrdatatransfer > domain in sendmessageusecase kt, fill in the function below and use json format to encode the list of results arraylist<trackeddata> into a string /*********************************************************************** * [practice 3] - encode heart rate & inter-beat interval into string * - encode function argument trackeddata into json format * - return the encoded string ----------------------------------------------------------------------- * - hint * use json encodetostring function **********************************************************************/ fun encodemessage trackeddata arraylist<trackeddata> string { //todo 3 } notetrackeddata is an object, containing data received from heart rate tracker’s single datapoint object @serializable data class trackeddata var hr int, var ibi arraylist<int> = arraylist 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 or mobile device see the instruction below on how to run unit tests right click on com samsung health hrdatatransfer test , and execute run 'tests in 'com samsung health hrdatatransfer" command if you have completed all the tasks correctly, you will see all the unit tests pass successfully run the app after building the apks, you can run the applications on your watch to measure heart rate and ibi values, and on your mobile device to collect the data from your watch once the app starts, allow the app to receive data from the body sensors afterwards, it shows the application's main screen to get the heart rate and ibi values, tap the start button tap the send button to send the data to your mobile device notethe watch keeps last ~40 values of heart rate and ibi you’re done! congratulations! you have successfully achieved the goal of this code lab now, you can create a health app on a watch to measure heart rate and ibi, and develop a mobile app that receives that health data! if you face any trouble, you may download this file heart rate data transfer complete code 213 9 kb to learn more about samsung health, visit developer samsung com/health
tutorials galaxy watch
bloghealth monitoring is a very popular feature in smart watches, and tizen provides various apis for this purpose. one api is humanactivitymonitor, which allows users to monitor health by providing metrics such as heart rate, step count, and stress level. this blog describes how to measure heart rate using this api. a sample web app combined with a widget is attached. this sample app measures heart rate and stores data by timestamp, and the widget shows the last measured heart rate. this blog focuses on how to measure heart rate using the device sensor, stored data, and communication between an app and a widget. create and run a tizen project 1. create a project in tizen studio. because our target is an app that is combined with a widget, select the widget template to create this project. 2. add the tizen advanced ui (tau) framework library to your project. you can create and manage various ui functionalities using the tau library as an alternative to designing a ui with html and css components. 3. link the tau.circle.min.css and tau.min.js in the app’s index.html file. <link rel="stylesheet" href="lib/tau/wearable/theme/default/tau.min.css"> <link rel="stylesheet" media="all and (-tizen-geometric-shape: circle)" href="lib/tau/wearable/theme/default/tau.circle.min.css"> <script src="lib/tau/wearable/js/tau.min.js"> </script> measure heart rate and manage data to measure heart rate using the humanactivitymonitor api, add the following feature and privilege to the config.xml file: <feature name="http://tizen.org/feature/humanactivitymonitor"/> <tizen:privilege name="http://tizen.org/privilege/healthinfo"/> applications must request a user’s permission for privacy-related features. the tizen.ppm.requestpermission() method invokes the permission pop-up. when users give permission through the pop-up, they can then use the app features related to that privilege. to measure heart rate, users must give permission to access the sensor using the following code snippet: function onsuccess() { function onchangedcb(hrminfo) { console.log(‘heart rate:’ + hrminfo.heartrate); tizen.humanactivitymonitor.stop('hrm'); } tizen.humanactivitymonitor.start('hrm', onchangedcb); } function onerror(e) { console.log("error " + json.stringify(e)); } tizen.ppm.requestpermission("http://tizen.org/privilege/healthinfo",onsuccess, onerror); note that the humanactivitymonitor api provides heart rate data directly in bpm (beats per minute). if you need the raw data of the sensor, you can use sensorhrmrawdata. the following screenshot shows how to measure heart rate using the sample app: the web storage api stores data in key-value format. this api offers two types of storage - local and session. in the sample, we use local storage, along with date as key and heartrate as value. the date key retrieves data according to date, week, and month. if you do not want to retrieve history according to date, you can use a different key, such as an integer value; just make sure there is no repetition in key value. create a date object to get the current time stamp. localstorage.setitem() puts the key (date)-value (heartrate) pair in local storage. var date_key = new date(); localstorage.setitem(date_key, hrminfo.heartrate); to retrieve data, filter according to the key. date and month are retrieved from the date object and filter data using localstorage.getitem(localstorage.key(i)). var date = new date(); var lastdate = new date(localstorage.key(i)); if (lastdate.getdate() == date.getdate() && lastdate.getmonth() == date.getmonth()) { console.log(localstorage.key(i)+ " :" + localstorage.getitem(localstorage.key(i))); the following screenshot shows how the history is categorized by day, week, and month: communication between the app and a widget the sample widget shows the last measured heart rate value, and heart rate history is stored in the local storage of the web app. to establish communication between the app and widget, we’ll use the preference api. the preference api stores key-pair values, allowing web widgets to communicate with their parent apps. in the app, data is stored with ‘key’: tizen.preference.setvalue('key', hrminfo.heartrate); in the widget, data is retrieved using the same ‘key’: if (tizen.preference.exists('key')) { console.log(‘last measured: ‘ + tizen.preference.getvalue('key')); } the following screenshot of the sample widget shows the last measured heart rate: launch the app from a widget to launch an app from widget, add the following privilege to config.xml: <tizen:privilege name="http://tizen.org/privilege/application.launch"/> to launch an app, provide your app id in tizen.application.launch(). tizen.application.launch(yourappid); in the sample widget, the user taps measure to launch the heart-rate measuring page or history to launch the heart-rate history page, and preference can be used to determine which one is clicked. to implement, a different key-value pair is set for each page in the widget, and in the web app, key values are checked to detect which page is clicked. for example, in the widget, the open_measure key is set to 1 to link to the measure page. the app then launches. tizen.preference.setvalue(‘open_measure’, 1); tizen.application.launch(yourappid); the app checks for the open_measure key. if the key exists, the user is redirected to the measure page with tau.changepage(). window.onload = function() { if (tizen.preference.exists(' open_measure ')) { tau.changepage(yourpageid); } } you can also use the humanactivitymonitor api to implement a step counter, stress level reading, gps, and other features in your wearable device. because enabling other features is similar to implementing the heart rate monitor, you can use this blog as a guide and the attached sampleheartratemonitor to enable a full range of health monitoring metrics to your galaxy watch.
Ummey Habiba Bristy
Learn Code Lab
codelabmeasure blood oxygen level and heart rate on galaxy watch objective create a health app for galaxy watch, operating on wear os powered by samsung, utilizing samsung health sensor sdk to trigger and obtain results of simultaneous blood oxygen level spo2 and heart rate measurements overview samsung health sensor 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 health sensor 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 and heart rate sample code 159 2 kb 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 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 in developer options find wireless debugging turn on wireless debugging check always allow on this network and tap allow go back to developer options and click turn off automatic wi-fi notethere may be differences in settings depending on your one ui version connect your galaxy watch to android studio go to settings > developer options > wireless debugging and choose pair new device take note of the wi-fi pairing code, ip address & port in android studio, go to terminal and type adb pair <ip address> <port> <wi-fi pairing code> when prompted, tap always allow from this computer to allow debugging after successfully pairing, type adb connect <ip address of your watch> <port> 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 turn on developer mode for health platform on your watch go to settings > apps > health platform quickly tap health platform title for 10 times this enables developer mode and displays [dev mode] below the title to stop using developer mode, quickly tap health platform title for 10 times to disable it start your project in android studio, click open to open existing project locate the downloaded android project from the directory and click ok establish service connection and check capabilities for the device to track data with the samsung health sensor sdk, it must connect to the service by healthtrackingservice api after establishing a connection, verify if the required tracker type is available to check this, get the list of available tracker types and verify that the tracker is on the list in this code lab, you will utilize blood oxygen level and heart rate trackers the healthtrackingservice api usage is in the table below healthtrackingservicehealthtrackingservice initiates a connection to samsung's health tracking service and provides a healthtracker instance to track a healthtrackertype public void connectservice establish a connection with samsung's health tracking service public void disconnectservice release a connection for samsung's health tracking service public healthtrackercapability gettrackingcapability provide a healthtrackercapability instance to get a supporting health tracker type list initialize multiple trackers before the measurement starts, initialize the spo2 tracker by obtaining the proper health tracker object in the connectionmanager java file, navigate to initspo2 , create an oxygen saturation healthtracker instance, and pass it to the spo2listener instance get the healthtracker object using the healthtrackingservice api use the healthtrackertype spo2_on_demand type as parameter healthtrackingservicehealthtrackingservice initiates a connection to samsung's health tracking service and provides a healthtracker instance to track a healthtrackertype public healthtracker gethealthtracker healthtrackertype healthtrackertype provide a healthtracker instance for the given healthtrackertype pass the healthtracker object to the spo2listener instance object spo2listener public void sethealthtracker healthtracker tracker set healthtracker instance for the given tracker /******************************************************************************************* * [practice 1] create blood oxygen level health tracker object * - get health tracker object * - pass it to spo2listener ------------------------------------------------------------------------------------------- * - hint replace todo 1 with parts of code * 1 get healthtracker object using healthtrackingservice gethealthtracker * use healthtrackertype spo2_on_demand type as parameter * 2 pass it to spo2listener using sethealthtracker function ******************************************************************************************/ public void initspo2 spo2listener spo2listener { //"todo 1 1 " //"todo 1 2 " sethandlerforbaselistener spo2listener ; } next, in the connectionmanager java file, in the initheartrate function, create a heart rate healthtracker instance, and pass it to the heartratelistener instance get the healthtracker object using the healthtrackingservice api use the healthtrackertype heart_rate_continuous type as parameter pass the healthtracker object to the heartratelistener instance object heartratelistener public void sethealthtracker healthtracker tracker set healthtracker instance for the given tracker /******************************************************************************************* * [practice 2] create heart rate health tracker object * - get health tracker object * - pass it to heartratelistener ------------------------------------------------------------------------------------------- * - hint replace todo 2 with parts of code * 1 get healthtracker object using healthtrackingservice gethealthtracker * use healthtrackertype heart_rate_continuous type as parameter * 2 pass it to heartratelistener using sethealthtracker function ******************************************************************************************/ public void initheartrate heartratelistener heartratelistener { //"todo 2 1 " //"todo 2 2 " sethandlerforbaselistener heartratelistener ; } start and stop trackers for the client app to start obtaining the data through the sdk, set a listener method on healthtracker this method will be called every time there is new data after the measurement completes, the listener has to be disconnected to start measurement in the baselistener java file, navigate to starttracker function, and set trackereventlistener as listener healthtracker object set an event listener on healthtracker object using healthtracking api use the healthtracker trackereventlistener object instance as parameter healthtrackerhealthtracker enables an application to set an event listener and get tracking data for a specific healthtrackertype public void seteventlistener healthtracker trackereventlistener listener set an event listener to this healthtracker instance /******************************************************************************************* * [practice 3] start health tracker by setting event listener * - set event listener on health tracker ------------------------------------------------------------------------------------------- * - hint replace todo 3 with parts of code * set event listener on healthtracker object using healthtracker seteventlistener * use trackereventlistener object as parameter ******************************************************************************************/ public void starttracker { log i app_tag, "starttracker called " ; log d app_tag, "healthtracker " + healthtracker tostring ; log d app_tag, "trackereventlistener " + trackereventlistener tostring ; if !ishandlerrunning { handler post -> { //"todo 3" sethandlerrunning true ; } ; } } to stop measurement, unset the trackereventlistener from the healthtracker object in the stoptracker function unset the event listener on healthtracker object using healthtracking api healthtrackerhealthtracker enables an application to set an event listener and get tracking data for a specific healthtrackertype public void unseteventlistener stop the registered event listener to this healthtracker instance /******************************************************************************************* * [practice 4] stop health tracker by removing event listener * - unset event listener on health tracker ------------------------------------------------------------------------------------------- * - hint replace todo 4 with parts of code * unset event listener on healthtracker object using healthtracker unseteventlistener ******************************************************************************************/ public void stoptracker { log i app_tag, "stoptracker called " ; log d app_tag, "healthtracker " + healthtracker tostring ; log d app_tag, "trackereventlistener " + trackereventlistener tostring ; if ishandlerrunning { //"todo 4" sethandlerrunning false ; handler removecallbacksandmessages null ; } } process obtained and batching data the response from the platform will be asynchronous with the results you want to obtain follow the steps below to get blood oxygen level and heart rate data in the spo2listener java file, navigate to updatespo2 function, and read spo2 data from datapoint get the oxygen saturation status using the datapoint api key valuekey spo2set status get the oxygen saturation value using the datapoint api key valuekey spo2set spo2 datapointdatapoint provides a map of valuekeyand value with a timestamp public <t>t getvalue valuekey<t> type get data value for the given key /******************************************************************************************* * [practice 5] read values from datapoint object * - get blood oxygen level status * - get blood oxygen level value ------------------------------------------------------------------------------------------- * - hint replace todo 5 with parts of code * 1 remove spo2status calculating and * set status from 'datapoint' object using datapoint getvalue valuekey spo2set status * 2 set spo2value from 'datapoint' object using datapoint getvalue valuekey spo2set spo2 * if status is 'spo2status measurement_completed' ******************************************************************************************/ public void updatespo2 datapoint datapoint { int status = spo2status calculating; //"todo 5 1 " int spo2value = 0; //"todo 5 2 " trackerdatanotifier getinstance notifyspo2trackerobservers status, spo2value ; log d app_tag, datapoint tostring ; } in the heartratelistener java file, navigate to readvaluesfromdatapoint function, and read the heart rate data from datapoint get heart rate status using datapoint api key valuekey heartrateset heart_rate_status get heart rate value using datapoint api key valuekey heartrateset heart_rate get heart rate ibi value using datapoint api key valuekey heartrateset ibi_list get ibi quality using datapoint api key valuekey heartrateset ibi_status_list /******************************************************************************************* * [practice 6] read values from datapoint object * - get heart rate status * - get heart rate value * - get heart rate ibi value * - check retrieved heart rate’s ibi and ibi quality values ------------------------------------------------------------------------------------------- * - hint replace todo 6 with parts of code * 1 set hrdata status from 'datapoint' object using datapoint getvalue valuekey heartrateset heart_rate_status * 2 set hrdata hr from 'datapoint' object using datapoint getvalue valuekey heartrateset heart_rate * 3 set local variable 'list<integer> hribilist' using datapoint getvalue valuekey heartrateset ibi_list * 4 set local variable 'final list<integer> hribistatus' using datapoint getvalue valuekey heartrateset ibi_status_list * 5 set hrdata ibi with the last of 'hribilist' values * 6 set hrdata qibi with the last of 'hribistatus' values ******************************************************************************************/ public void readvaluesfromdatapoint datapoint datapoint { heartratedata hrdata = new heartratedata ; //"todo 6 1 " //"todo 6 2 " //"todo 6 3 " //"todo 6 4 " //"todo 6 5 " //"todo 6 6 " trackerdatanotifier getinstance notifyheartratetrackerobservers hrdata ; log d app_tag, datapoint tostring ; } run unit tests for your convenience, you can find an additional unit tests package this lets you verify your code changes even without using a physical watch see instructions below on how to run unit tests right click on com samsung health multisensortracking test and execute run 'tests in 'com samsung health multisensortracking'' command if you completed all the tasks correctly, you can see that all the unit tests passed successfully run the app after building the apk, you can run the application on a connected device to see blood oxygen level and heart rate values right after the app is started, it requests for user permission allow the app to receive data from the body sensors afterwards, it shows the application's main screen and automatically display the heart rate to get the blood oxygen level spo2 value, tap on the measure button to stop the measurement, tap on the stop button tap on the details label to see more heart rate data 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 and heart rate by yourself! if you're having trouble, you may download this file measuring blood oxygen level and heart rate complete code 158 8 kb to learn more about samsung health, visit developer samsung com/health
tutorials health, galaxy watch
blogthis is the third blog in a series to introduce the sample application workout, a tizen example for monitoring health sensors on a wearable device. the first blog, workout -- a tizen sample app for monitoring health sensors, presented the basic features of the application. the second blog, adding distance traveled to the tizen workout sample app, described how distance traveled is calculated. in this blog, i will demonstrate another key feature of the app, heart rate measurement (hrm), which shows the most recent heart rate intensity. implementation to start collecting data from the hrm sensor, first start tizen.sensor.heartratemonitor from tizenfx api. heartratemonitorservice.cs public void init() { try { _hrm = new hrm { interval = 1000, pausepolicy = sensorpausepolicy.none }; _hrm.dataupdated += ondataupdated; } catch (exception) { notsupported?.invoke(this, eventargs.empty); } } initiating hrm in this way invokes dataupdated every one second and the sensor is not stopped even when the application is sent to the background. the data from the event is handled by the ondataupdated handler, which invokes the event with the single bpm value. this event is listened to by the onservicedataupdated handler in the heartratemonitormodel, where all information related to heart rate is calculated: heartratemonitormodel.cs private void onservicedataupdated(object sender, int bpm) { double normalizedbpm = math.clamp((bpm - _minbpm) / (double)(_maxbpm - _minbpm), 0, 1); int bpmrange = bpm < _minbpm ? 0 : math.min((int)((normalizedbpm * (_bpmranges - 1)) + 1), _bpmranges - 1); if (!_ismeasurementpaused) { _bpmrangeoccurrences[bpmrange]++; } updated?.invoke(this, new heartratemonitorupdatedeventargs(new heartratemonitordata { bpm = bpm, bpmrange = bpmrange, bpmrangeoccurrences = _bpmrangeoccurrences, normalizedbpm = normalizedbpm })); } however, let's start with the values that are used in the above method: _maxbpm - this value is calculated during the class instantiation according to the formula: 220 - user age _minbpm - this is half the value of _maxbpm _minbpm and _maxbpm is used to calculate normalizedbpm, a value ranging from 0 to 1. next, the bpmrange to which the current hrm service value belongs is calculated: for bpm below _minbpm, bpmrange is set to 0. for bpm greater than or equal to _minbpm, bpmrange is set to either (_normalizedbpm * (_bpmranges -1) + 1) or (_bpmranges - 1), whichever value is smaller. this calculated pulse interval is used as a position in an array, whose value is increased by 1. to obtain the most common pulse interval, find the index with the highest value associated with it. detailspageviewmodel.cs intensity = array.lastindexof(bpmrangeoccurrences, bpmrangeoccurrences.max()).tostring(); to display the range indication, intensity is delivered to xaml and converted into text using a converter. detailspageview.xaml.cs <models:detailsitemdata name="intensity" value="{binding intensity, converter={staticresource bpmrangevalueconverter}}" icon="images/details_intensity_icon.png" isactionbuttonvisible="true"> read more to learn more about the implementation of the hrm sensor and the use of the data in the workout app, see this tutorial in the final blog of this series, you'll learn how circlelistview is used in the app.
Patryk Falba
Develop Health
apioverviewpackageclasstreedeprecatedindex com samsung android sdk healthdata interface healthconstants heartrate all superinterfaces healthconstants common, healthconstants sessionmeasurement enclosing class healthconstants public static interface healthconstants heartrate extends healthconstants sessionmeasurement this interface defines heart rate data of the user properties properties of the following extending interfaces are available for this data type healthconstants common healthconstants sessionmeasurement heart rate data has the following properties see more common properties by spreading this section out property name description healthconstants heartrate uuid [mandatory] data's unique id, assigned by the system when a new data is inserted healthconstants heartrate create_time [mandatory] utc milliseconds when a data is created in the health data store, assigned by the system when a new data is inserted healthconstants heartrate update_time [mandatory] utc milliseconds when a data is updated in the health data store, assigned by the system when a new data is inserted or the existing data is updated healthconstants heartrate package_name [mandatory] package name which provides data, assigned by the system when a new data is inserted healthconstants heartrate device_uuid [mandatory] device identifier which provides the health data healthconstants heartrate start_time [mandatory] utc milliseconds when the measurement is started healthconstants heartrate end_time [mandatory] utc milliseconds after the measurement has ended healthconstants heartrate time_offset [mandatory] time offset in milliseconds which considers the time zone and daylight saving time healthconstants heartrate heart_rate [mandatory] heart rate value healthconstants heartrate heart_beat_count total heart beat count for measurement time healthconstants heartrate min min value in binning_data healthconstants heartrate max max value in binning_data healthconstants heartrate binning_data continuous heart rate healthconstants heartrate comment comment healthconstants heartrate custom custom info which is formatted with json and compressed data data permission the user's consent is required to read or write this data type healthpermissionmanager requestpermissions displays a data permission ui to the user see permission manager and request data permission since 1 0 0 field summary fields modifier and type field and description static string binning_data continuous heart rate which is formatted with json and compressed data static string comment comment for data static string health_data_type data type name for heart rate data static string heart_beat_count total heart beat count for measurement time static string heart_rate heart rate value, beats per minute bpm static string max max value in binning_data static string min min value in binning_data fields inherited from interface com samsung android sdk healthdata healthconstants sessionmeasurement end_time, start_time, time_offset fields inherited from interface com samsung android sdk healthdata healthconstants common create_time, custom, device_uuid, package_name, update_time, uuid field detail heart_rate static final string heart_rate heart rate value, beats per minute bpm mandatory type float value range 0 ~ 300 since 1 0 0 see also constant field values heart_beat_count static final string heart_beat_count total heart beat count for measurement time mandatory type int value range 0 and above since 1 0 0 see also constant field values comment static final string comment comment for data optional type string value length 0 ~ 255 since 1 0 0 see also constant field values min static final string min min value in binning_data optional type float value range 0 ~ 300 since 1 3 0 see also constant field values max static final string max max value in binning_data optional type float value range 0 ~ 300 since 1 3 0 see also constant field values binning_data static final string binning_data continuous heart rate which is formatted with json and compressed data optional type byte[] maximum data size 1000 kb binning data can have one or more segment each segment is composed of the following json keys json key type unit mandatory "heart_rate" float beat per minute yes set this value if you save binning_data "heart_rate_min" float beat per minute yes set this value if you save binning_data "heart_rate_max" float beat per minute yes set this value if you save binning_data "start_time" long utc millisecond yes set this value if you save binning_data "end_time" long utc millisecond yes set this value if you save binning_data the following example shows the json format for binning_data { "heart_rate" 147 48181, "heart_rate_min" 99 0, "heart_rate_max" 124 0, "start_time" 1422457096536, "end_time" 1493922600000 } compressed json conversion can be converting data to compressed json getting data from compressed json since 1 3 0 see also healthdatautil, constant field values health_data_type static final string health_data_type data type name for heart rate data use "com samsung health heart_rate" to add permission to the manifest file since 1 0 0 see also constant field values
Develop Health
apioverviewpackageclasstreedeprecatedindex com samsung android sdk healthdata interface healthconstants electrocardiogram all superinterfaces healthconstants common, healthconstants sessionmeasurement enclosing class healthconstants deprecated 1 5 0 this data type will be removed do not use it any more public static interface healthconstants electrocardiogram extends healthconstants sessionmeasurement this interface defines electrocardiogram data of the user properties properties of the following extending interfaces are available for this data type healthconstants common healthconstants sessionmeasurement electrocardiogram data has the following properties see more common properties by spreading this section out property name description healthconstants electrocardiogram uuid [mandatory] data's unique id, assigned by the system when a new data is inserted healthconstants electrocardiogram create_time [mandatory] utc milliseconds when a data is created in the health data store, assigned by the system when a new data is inserted healthconstants electrocardiogram update_time [mandatory] utc milliseconds when a data is updated in the health data store, assigned by the system when a new data is inserted or the existing data is updated healthconstants electrocardiogram package_name [mandatory] package name which provides data, assigned by the system when a new data is inserted healthconstants electrocardiogram device_uuid [mandatory] device identifier which provides the health data healthconstants electrocardiogram start_time [mandatory] utc milliseconds when the measurement is started healthconstants electrocardiogram end_time [mandatory] utc milliseconds after the measurement has ended healthconstants electrocardiogram time_offset [mandatory] time offset in milliseconds which considers the time zone and daylight saving time healthconstants electrocardiogram sample_frequency [mandatory] sampling frequency of heart beats healthconstants electrocardiogram sample_count [mandatory] sample count of heart beats healthconstants electrocardiogram data [mandatory] ecg data healthconstants electrocardiogram data_format [mandatory] data format for the ecg diagram healthconstants electrocardiogram max_heart_rate maximum value of heart rate healthconstants electrocardiogram mean_heart_rate mean value of heart rate healthconstants electrocardiogram min_heart_rate minimum value of heart rate healthconstants electrocardiogram comment comment healthconstants electrocardiogram custom custom info which is formatted with json and compressed data data permission the user's consent is required to read or write this data type healthpermissionmanager requestpermissions displays a data permission ui to the user see permission manager and request data permission since 1 0 0 field summary fields modifier and type field and description static string comment deprecated comment for data static string data deprecated ecg data static string data_format deprecated data format for the ecg diagram static string health_data_type deprecated data type name for electrocardiogram data static string max_heart_rate deprecated maximum value of heart rate static string mean_heart_rate deprecated mean value of heart rate static string min_heart_rate deprecated minimum value of heart rate static string sample_count deprecated sample count of heart beats static string sample_frequency deprecated sampling frequency of heart beats fields inherited from interface com samsung android sdk healthdata healthconstants sessionmeasurement end_time, start_time, time_offset fields inherited from interface com samsung android sdk healthdata healthconstants common create_time, custom, device_uuid, package_name, update_time, uuid field detail max_heart_rate static final string max_heart_rate deprecated maximum value of heart rate optional type float value range 0 ~ 300 since 1 0 0 see also constant field values mean_heart_rate static final string mean_heart_rate deprecated mean value of heart rate optional type float value range 0 ~ 300 since 1 0 0 see also constant field values min_heart_rate static final string min_heart_rate deprecated minimum value of heart rate optional type float value range 0 ~ 300 since 1 0 0 see also constant field values sample_frequency static final string sample_frequency deprecated sampling frequency of heart beats mandatory type int value range 0 and above since 1 0 0 see also constant field values sample_count static final string sample_count deprecated sample count of heart beats mandatory type int value range 0 and above since 1 0 0 see also constant field values data static final string data deprecated ecg data mandatory type byte[] maximum data size 1000 kb compressed json conversion can be converting data to compressed json getting data from compressed json since 1 0 0 see also healthdatautil, constant field values data_format static final string data_format deprecated data format for the ecg diagram mandatory type string value length 1 ~ 32 since 1 0 0 see also constant field values comment static final string comment deprecated comment for data optional type string value length 0 ~ 255 since 1 0 0 see also constant field values health_data_type static final string health_data_type deprecated data type name for electrocardiogram data use "com samsung health electrocardiogram" to add permission to the manifest file since 1 0 0 see also constant field values
Learn Code Lab
codelabcreate a watch face using tag expressions objective learn how to create a watch face that responds based on the date, time, step count, heart rate, and battery level using tag expressions in watch face studio in this code lab, you will create a basic watch face with complications such as step count, heart rate, and battery level later, you will improve its functionalities and make it visually dynamic using tag expressions overview watch face studio is a graphic authoring tool that enables you to create watch faces for wear os it offers a simple and intuitive way to add images and components, and to configure the watch movement without any coding watch face studio supports watch faces for the galaxy watch4 or newer version, and other watch devices that run on the same platform tag expressions are conditions in watch face studio that allows you to customize watch face through dynamic configuration of its movement and data set up your environment you will need the following watch face studio galaxy watch4 or newer any supported wear os watch start your project create a new project and input project name a blank studio will show upon clicking ok add analog hands and index watch face studio allows you to add components like text, image, shape, analog hands, and index in a watch face for your watch to have the look and feel of an analog watch, add the following components time > index time > analog hands > minute time > analog hands > hour notethe index and watch hand images used in this code lab are no longer included in the latest version of the watch face studio however, you can choose a design for the index and watch hands from available images in the resources folder you can also create and add your own design you will see that the hands move automatically and in sync with the device time select all the newly added components and click group rename the group as group_analogtime use a progress bar for seconds a component like a progress bar can be used to show how much of the process is completed and how much is left in this step, you will use it to show how far or close the next minute is to use a progress bar as seconds click add component and select progress bar rename the component to seconds move seconds behind group_analogtime in properties of seconds, do the following a adjust the dimension width and height to 395 b align the component to the center c drag the background slider to 0% d make sure that the type is a circular progress bar; otherwise change it e in range setting, change value to 0 and click tags beside it to open the tags window f type in [sec] it means that the value from 0 will increment as the value of the second increases g set max value to 59 since it is the maximum value of [sec] notein this scenario, the progress bar disappears in the canvas as the preview only uses the base value, which is 0 however, the component is still present in run format and position a digital clock in this step, you will learn how grouping works and affects its components you will also learn how to format the date and time using tags to format and position a digital clock, you need to add a digital clock > time twice rename them as hour and minute, respectively add a digital clock > date and rename the component as date put them in one group and rename it as group_digitaltime go to the properties of hour and change the text appearance to 80 do the same for minute adjust the text size of date to 15 adjust the y placements of the individual components to look like the image below when you change a certain component, it won’t affect other components in the group format hour to only show the time in hour a go to its properties and click the tags button in text field b replace text field value with [hour_0_23_z] to show the current hour with leading zero do the same for minute but replace the text field value with [min_z] to show the current minute in an hour with leading zero go to group_digitaltime placement properties and align it horizontally after that, place it to the left you will see the components adjusted as a group utilize health features and battery level watch face studio also allows you to utilize data like step count, heart rate, and battery level follow the steps below to show these real-time data using tags on texts or progress bar battery level add a circular progress bar and rename the component as battery level drag the background slider to 0% go to value properties replace the value with 0 and, in tags, input or choose [batt_per] to use the current battery percentage as the value add a circle complication slot and rename it as battery icon complications are a set of components that can be handled as one group set the type to fixed and change the default provider to watch battery select short text as complication type and choose icon + text for layout select and move battery level and battery icon together to the bottom right heart rate add a circular progress bar and rename the component as heart rate drag the background slider to 0% go to value properties replace the value with 0 and, in tags, input or choose [hr] to use heart rate as value set the max value to 240 since it's the maximum heart rate a person can have add a text component and rename it as heart rate label in the text field, input heart rate and change the text size to 12 change the y placement to 195 add another text component and rename it as heart rate text in the text field, input [hr] and change the text size to 30 group heart rate, heart rate label, and heart rate text together rename the group as group_heartrate move the group_heartrate placement to the center right step count add a circular progress bar and rename the component as step count drag the background slider to 0% go to value properties replace the value with 0 and, in tags, input or choose [sc_per] to use the current percentage to the goal of step count add a circle complication slot and rename it as step count text set the type to fixed and change the default provider to step count select short text as complication type and choose text + title for layout it will now show "steps" as title and step count as text place the step count text in the center horizontally select and move step count and step count text together to the top right select group_digitaltime, group_batterylevel, group_heartrate, group_stepcount, battery icon, and step count text drag them behind group_analoghands and seconds by doing this, the analog hands would overlap the components make use of tag expressions you already have three progress bars that show data of battery level, heart rate, and step count this time, you will make these features more functional by changing the progress bars' color to red using tag expressions tag expressions are conditions that allow you to change the rotation, placement, behavior, and opacity of a component based on tag values it can alter your watch face's appearance dynamically as the tag value changes tag expressions support different types of operators – arithmetic, relational, logical, and ternary for this step, you will apply tag expressions on the color opacity but first, you will have to duplicate all the circular progress bars seconds, battery level, heart rate, and step count move all the duplicates to a new group called group_colorchange make sure that group_colorchange is behind all other groups change individual component’s color to #ffffff or white duplicate this group and rename it as group_background move it behind group_colorchange drag the background slider to 16% and remove tags in the value properties of each component of group_background change group_colorchange color to #ff001e or red group_colorchange will be used as components underneath when you set the opacity of the main components to 0 using tag expressions group_background will serve as gap fillers of each progress bar below are conditions that will trigger the opacity of the main components to become 0 and reveal the duplicated red components change the color of the battery level to red if the battery level is equal to or less than 20% go to group_batterylevel and select battery level navigate to color properties check if the color opacity value is 100 this will serve as the base value in tags, input [batt_per]<=20?-100 0 to subtract 100 from the base value of opacity if the battery level is equal to or less than 20 otherwise, the base opacity value remains the same in the run pane, adjust the device > watch battery to 20% or less, and you will see how the color will change to red change the color of step count to red if the goal hasn't been reached yet and the time is already 18 00 6 00 pm or beyond go to group_stepcount and select step count navigate to color properties check if the color opacity value is 100 this will serve as the base value in tags, input [sc]<[sc_goal] * [hour_0_23]>=18 ?-100 0 to subtract 100 from the base value of opacity if the step count is less than the goal, and if the value of hour in a day is 18 or beyond otherwise, the base opacity value remains the same play with the time control bar in the run pane and health > steps data to see how the color will change from blue to red change the color of the heart rate and seconds to red if the heart rate is below or above the normal go to group_heartrate and select heart rate navigate to color properties check if the color opacity value is 100 this will serve as the base value in tags, input [hr]<60 + [hr]>100 ?-100 0 to subtract 100 from the base value of opacity if the heart rate is below or above the normal 60-100 otherwise, it remains the same do the same for seconds test it in the run pane by adjusting the health > heart rate to below 60 or above 100, and you will see how the color will change to red prolong the battery life now that you already know what group and tag expressions are, it's about time for you to use both to your advantage it is observed that the darker a watch face design is, the longer the battery life can be to help the watch stay powered even when there’s a little battery left, you will need to decrease the opacity of the watch face when the battery level is equal to or less than 10% to do this, you have to select and combine all created groups and components, except for group analogtime, battery icon, and step count text, to a new group called group_watchface go to group_watchface color properties and change the base opacity value to 20 in tags, input [batt_per]<=10?0 80 to add 0 to the base value of opacity if the battery level is equal to or less than 10 otherwise, it adds 80 to the base value, making the watch face 100% visible adjust the device > watch battery to 10% or less, and you will see how most components' opacity decreased choose components for always-on always-on display is a feature that allows your galaxy watch to show the time without checking on it by pressing a button or lifting your hand in watch face studio, you can choose which group or component to display on the always-on by following these steps go to the always-on tab, to see the same set of components you added and grouped click the eye icon next to the group name to hide or make it visible hide group_watchface, battery icon, and step count text at this point, your always-on display will display a basic analog watch face whenever your watch is in idle mode test the watch face to test your watch face, you need to connect a watch device to the same network as your computer in watch face studio, select project > run on device select the connected watch device you want to test with if your device is not detected automatically, click scan devices to detect your device or enter its ip address manually by clicking the + button you're done! congratulations! you have successfully achieved the goal of this code lab now, you can create and design a watch face using tag expressions by yourself! if you're having trouble, you may download this file tag expression complete project 272 71 kb to learn more about watch face studio, visit developer samsung com/watch-face-studio
Develop Galaxy Watch for Tizen
docprovided complications the following are sample complications provided with galaxy watch studio time image name description date_digital_a a digital clock that displays the day of the month on a black square background and consists of a digital clock component and image date_digital_b a digital clock that displays the day of the month on a circular background and consists of a digital clock component and image dayofweek_analog a watch hand that designates the day of the week and consists of a watch hand component and image dayofweek_digital a digital clock that designates the day of the week and consists of a digital clock component and image month_analog_a a watch hand that designates the numerical month of the year and consists of a watch hand component and image month_analog_b a watch hand that designates the numerical month of the year and consists of a watch hand component and image second_analog_a a watch hand that designates seconds and consists of a watch hand component and image second_analog_b a watch hand that designates seconds and consists of a watch hand component and image second_analog_c a watch hand that designates seconds and consists of a watch hand component and image second_analog_d a watch hand that designates seconds and consists of a watch hand component and image second_analog_e a watch hand that designates seconds and consists of a watch hand component and image battery image name description analog_01 images that show battery status tap to open the battery status app there are 54 images that make up this complication the gauge images 1 and 4 - 53 , the battery icon images 2 and 3 , and the area that can be tapped to open the battery status app image 54 the gauge visually represents the battery percentage the higher the battery percentage, the more marks are filled in the gauge if the battery percentage is below 20%, the filled-in marks are orange if the battery percentage is greater than or equal to 20%, the filled-in marks are green the battery icon displays one of two images if the battery percentage is below 20%, a warning battery image is displayed if the battery percentage is greater than or equal to 20%, a normal battery is displayed the images that are displayed are determined by conditional lines based on the battery percentage for example, the low battery image image 3 is activated when the battery percentage is less than 20% analog_02 images and watch hands that show battery status tap to open the battery status app there are four images and two watch hands that make up this complication image 1 is the gauge, images 2 and 3 are the battery icon, and image 4 is the area that can be tapped to open the battery status app the watch hands are synced with the battery percentage the battery icon displays one of two images if the battery percentage is below 20%, a warning battery image is displayed if the battery percentage is greater than or equal to 20%, a normal battery is displayed the battery image that is displayed is determined by conditional lines based on the battery percentage for example, the low battery image image 3 is activated when the battery percentage is less than 20% digital images and text that show battery status tap to open the battery status app there are 24 images and a text component that make up this complication images 1 - 21 are the gauge, images 22 and 23 are battery icon, and image 24 is the area that can be tapped to open the battery status app the text component is synced with the battery percentage the gauge visually represents the battery percentage the higher the battery percentage, the more marks are filled in the gauge the battery icon displays one of two images if the battery percentage is below 15%, an empty battery image is displayed if the battery percentage is greater than or equal to 15%, a filled-in battery image is displayed the images that are displayed are determined by conditional lines based on the battery percentage for example, the low battery image image 22 is activated when the battery percentage is less than or equal to 15% workout image name description speed_analog watch hand and images that show walking speed tap to open s health app steps speed speed_digital text and image that show walking speed tap to open s health app steps speed steps_analog_a images and watch hands that show step percentage tap to open the s health app steps there are three images and two watch hands that make up this complication image 1 is the gauge and the area that can be tapped to open the s health app and images 2 and 3 are the shoe icon the watch hands are synced with the step percentage the shoe icon displays one of two images if the steps percentage is below 80%, an empty shoe image is displayed if the steps percentage is greater than or equal to 80%, a filled in shoe in a circle is displayed the shoe image that is displayed is determined by conditional lines based on the steps percentage for example, the empty shoe image image 2 is activated when the steps percentage is less than 80% steps_analog_b images and watch hands that show step percentage tap to open the s health app steps there are three images and two watch hands that make up this complication image 1 is the gauge and the area that can be tapped to open the s health app and images 2 and 3 are the shoe icon the watch hands are synced with the step percentage the shoe icon displays one of two images if the steps percentage is below 80%, an empty shoe image is displayed if the steps percentage is greater than or equal to 80%, a filled in shoe in a circle is displayed the shoe image that is displayed is determined by conditional lines based on the steps percentage for example, the empty shoe image image 2 is activated when the steps percentage is less than 80% steps_digital_a text and image that show number of steps tap to open s health app steps steps_digital_b text and images that show the number of steps taken, steps goal, and steps percentage the images change, depending on the percentage of steps taken towards the goal there are three images that may be displayed the first image is a man standing still that is displayed when the step percentage is 0 the second image is a running man that is displayed when the step percentage is less than or equal to 99 its position is also adjusted horizontally to the right as the step percentage increases the third image is a man with raised arms that is displayed when the step percentage is equal to 100 each image uses a tag expression that defines its opacity to determine if it is displayed additionally, the running man image uses a tag expression that defines its location on the watch face water image name description water_a text and image that show amount of water consumed tap to open s health app water water_b text and image that show amount of water consumed tap to open s health app water water_c text and image that show amount of water consumed tap to open s health app water caffeine image name description caffein_a text and image that show amount of caffeine consumed tap to open s health app caffeine caffein_b text and image that show amount of caffeine consumed tap to open s health app caffeine caffein_c text and image that show amount of caffeine consumed tap to open s health app caffeine heart rate image name description heart_01 text and image that show heart rate tap the icon to open s health app measuring heart rate heart_02 text and image that show heart rate tap the icon to open s health app measuring heart rate heart_03 text that shows the heart rate and an animated image that changes, depending on the heart rate there are three images that may be displayed the first image is white and pulses slowly if the heart rate is less than or equal to 50 the second image is gold and pulses at a medium speed if the heart rate is greater than 50 or less than or equal to 100 the third image is red and pulses quickly if the heart rate is greater than 100 each image uses a tag expression that defines its location on the watch face effect image name description autoban background image of cars on the road that responds to the watch's tilt position and angle cube background image of a cube that responds to the watch's tilt position and angle gyro_effect_sample_dance background image of dancers that responds to the watch's tilt position and angle leveler background image of concentric circles that responds to the watch's tilt position and angle light_effect background image of reflection that responds to the watch's tilt position and angle wave background image of a ripple that responds to the watch's tilt position and angle
We use cookies to improve your experience on our website and to show you relevant advertising. Manage you settings for our cookies below.
These cookies are essential as they enable you to move around the website. This category cannot be disabled.
These cookies collect information about how you use our website. for example which pages you visit most often. All information these cookies collect is used to improve how the website works.
These cookies allow our website to remember choices you make (such as your user name, language or the region your are in) and tailor the website to provide enhanced features and content for you.
These cookies gather information about your browser habits. They remember that you've visited our website and share this information with other organizations such as advertisers.
You have successfully updated your cookie preferences.