Filter
-
Content Type
-
Category
Mobile/Wearable
Visual Display
Digital Appliance
Platform
Recommendations
Filter
Design One UI Watch for Tizen
doclifestyle photo assets for galaxy store looking to include lifestyle photos on your galaxy store product detail pages? show off your amazing watch face designs by taking advantage of our lifestyle photo assets. simply paste your watch face into our "smart" photoshop files and your design will automatically appear on the actual watch—with correct perspective, shading and more. it's that simple! read: add your watch face design to smart lifestyle photos build your own lifestyle photos watch the video and learn how to take lifestyle photos and then turn them into “smart” photoshop files. these photoshop files allow you to quickly place your watch app or watch face design onto the watch in the photo. download lifestyle photo assets and save time! click on a watch below to browse a collection of lifestyle photo assets for the selected watch type. notegalaxy store supports watch faces for galaxy watch3 and earlier (samsung watches running on tizen). watch faces for galaxy watch4 and later (running on wear os powered by samsung) are only supported in play store and the chinese galaxy store. lifestyle photo assets for play store to make publishing easier for watch face designers on play store, download the lifestyle photo assets for play store. see lifestyle photo assets for play store for more information.
Design One UI Watch for Tizen
docgalaxy store asset creator watch face marketing assets made easy if you’re serious about your watch face designs appealing to a wide audience, it’s important to put thought and effort into how your content is displayed in app stores. thanks to the galaxy store asset creator, creating a professional-looking product detail page is no longer a time-consuming endeavor. download: galaxy store asset creator (version 2.2) read: create eye-catching galaxy store listings with the watch asset creator how does it work? the asset creator is a photoshop template that uses multiple artboards and the generate image asset feature. as you work with the artboards, each asset is updated with your current artwork. these assets include the icon shown in the galaxy store directory, the cover image that appears at the top of the watch face product detail page, as well as the product image screenshots. quick & easy simply place your watch face onto one artboard and all watches are updated with your design. choose from different samsung watch models and different product layouts. customize the background and layout to make your product detail page unique. no need to worry about individually exporting the assets. the asset creator auto-exports all required assets into a single folder and at the required sizing. in order to take advantage of the tool’s special features, you must use photoshop version 16.0 (cc 2015) or later and have a basic understanding of photoshop. earlier versions can open the file, but functionality may be limited. download the galaxy store asset creator to get started! download: galaxy store asset creator (version 2.2) lifestyle photo asset packs check out the collection of downloadable photos on the lifestyle photo assets for galaxy store page. play store asset creator to make publishing easier for watch face designers on play store, download the play store asset creator, which includes the latest samsung galaxy watches for wear os powered by samsung. see play store asset creator for more information.
Learn Code Lab
codelabcreate a daily step counter on galaxy watch objective create a native app for galaxy watch, operating on wear os powered by samsung, using health platform to read your daily steps overview health platform provides a unified and straightforward way for accessing a wide range of health and wellness related data with health platform api, you may easily read and write data stored in health platform on android and wear os powered by samsung applications can have access to these secured data only with explicit user consent additionally, users may disable access to the data at any point in time see health platform 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! health step count sample code 119 87 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 stepcount from the directory and click ok check dependency and app manifest in the dependencies section of stepcount/app/build gradle file, see the appropriate dependency for health platform dependencies { implementation com google android libraries healthdata health-data-api 1 0 0-alpha01' // } notelibrary might update from time to time if necessary, choose the version suggested by android studio request for data permissions before accessing any data through health platform, the client app must obtain necessary permissions from the user in permissions java, create a permission instance to trigger relevant permission screen and obtain required consent from end user data type name intervaldatatypes steps read access accesstype read /******************************************************************************************* * [practice 1] build permission object grand permissions for read today's steps * - set interval data type of steps * - set read access type ------------------------------------------------------------------------------------------- * - hint uncomment lines below and fill todos with * 1 for interval data type intervaldatatypes steps * 2 for read access accesstype read ******************************************************************************************/ permission stepsreadpermission = permission builder // setdatatype "todo 1 1 " // setaccesstype "todo 1 2 " build ; make a query to aggregate today’s steps create read request with all necessary information to read data through health platform api the answer from the platform will be asynchronous with the result from which you can get all the data you are interested in follow the steps below to get today's steps count in stepsreader java, create a readaggregateddatarequest with cumulativeaggregationspec instance data type name intervaldatatypes steps /******************************************************************************************* * [practice 2] build read aggregated data request object for read today's steps * - set interval data type of steps ------------------------------------------------------------------------------------------- * - hint uncomment line below and fill todo 2 with * 1 for interval data type intervaldatatypes steps ******************************************************************************************/ readaggregateddatarequest readaggregateddatarequest = readaggregateddatarequest builder settimespec timespec builder setstartlocaldatetime localdatetime now with localtime midnight build // addcumulativeaggregationspec cumulativeaggregationspec builder "todo 2 1 " build build ; read cumulative steps count from cumulativedata set variable steps value to 0l it is the count of daily steps get aggregatedvalue object using cumulativedata api cumulativedataaggregateddata representing total of intervaldata over a period of time e g total steps in a day public aggregatedvalue gettotal check the result if it is not null, get aggregated value using aggregatedvalue api aggregatedvaluevalue fields aggregated over a period of time only numeric fields longfield, doublefield can be included in aggregation public long getlongvalue returns all longfields and their values that are already set add value to the daily steps result counter /******************************************************************************************* * [practice 3] read aggregated value from cumulative data and add them to the result * - get aggregatedvalue from cumulativedata object * - get steps count from aggregatedvalue object ------------------------------------------------------------------------------------------- * - hint uncomment lines below and replace todo 3 with parts of code * 1 get aggregatedvalue object 'obj' using cumulativedata gettotal * 2 get value using obj getlongvalue and add to the result ******************************************************************************************/ long steps = 0l; if result != null { list<cumulativedata> cumulativedatalist = result getcumulativedatalist ; if !cumulativedatalist isempty { for cumulativedata cumulativedata cumulativedatalist { //"todo 3 1 " //"todo 3 2 " } } } return steps; 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 instruction below on how to run unit tests right click on com samsung sdc21 stepcount test and execute run 'tests in 'com samsung sdc21 stepcount'' 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 see real-life aggregated steps count measured by a smartwatch right after the app is started, it will request for the user permission allow the app to receive data of the activity afterwards, the application main screen will be shown it will automatically display today’s step count tap on refresh button to read current steps count from health platform you're done! congratulations! you have successfully achieved the goal of this code lab now, you can create a daily step counter app by yourself! if you're having trouble, you may download this file health step count complete code 119 79 kb learn more by going to health platform
Learn Code Lab
codelabtrack deadlift exercise on galaxy watch objective create a native app for galaxy watch, operating on wear os powered by samsung, using health services to track deadlift exercise this app measures repetition count, calories burned, and time spent during the exercise overview health services provides a simple and unified way for accessing a wide range of health and wellness related data with health services api, you will no longer need to develop your own algorithms processing sensors data in order to compute metrics like heart rate, steps counts, distance, calories burned, and other more these are now accessible through health services embedded on wearables operating on wear os powered by samsung see health platform 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! health track deadlift sample code 132 83 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, open your android studio and click open to open an existing project locate the downloaded android project deadlift from the directory and click ok check dependency and app manifest in the dependencies section of gradle scripts > build gradle module app file, see the appropriate dependency for health services dependencies { implementation 'androidx health health-services-client 1 0 0-beta03' // } notesince the library might update from time to time, it is recommended to choose the version suggested by android studio in androidmanifest xml file, note the following <queries> element <queries> <package android name="com google android wearable healthservices" /> </queries> section with requests for necessary permissions <uses-permission android name="android permission body_sensors" /> <uses-permission android name="android permission activity_recognition" /> check capabilities to check what can be measured during an exercise, you need to check its capabilities go to app > java > com samsung sdc21 deadlift open the deadliftutil java file and navigate to the checkcapabilities method an inner class c definition implements the methods of the futurecallback interface within this definition, define the onsuccess method to retrieve the exercise type capabilities public void onsuccess exercisecapabilities result { objects requirenonnull result ; log i tag, "got exercise capabilities" ; /*********************************************************************************** * [practice 1] define the onsuccess method * * - hint uncomment lines below and replace todo 1 * call getexercisetypecapabilities method of result object, * passing already initialized t as an argument **********************************************************************************/ final exercisetype t = exercisetype deadlift; // final exercisetypecapabilities capabilities = "todo 1" // final exerciseconfig builder builder = exerciseconfig builder t ; // builder setdatatypes capabilities getsupporteddatatypes ; // exerciseconfigbuilder = builder; } next, implement the findcapabilitesfuture method to get a callback with exercisecapabilities getcapabilitiesasync returns the exercisecapabilities of the exerciseclient for the device static listenablefuture<exercisecapabilities> findcapabilitiesfuture exerciseclient client { /******************************************************************************************* * [practice 1] create a listenablefuture object that will get a callback with * with exercise capabilities choose the correct method from exerciseclient * * - hint uncomment line and replace null with todo 2 * for checking capabilities use getcapabilitiesasync method ******************************************************************************************/ return null; //"todo 2"; } start the exercise inside the startexercise method, there is a call to the futures addcallback method this method adds a callback function that executes when the asynchronous operation of starting the exercise completes set an update callback for the exercise client within the onsuccess method of the callback function public void onsuccess void result { log i tag, "successfully started" ; /*************************************************************************** * [practice 2] set an update callback * * - hint uncomment lines below and fill todos * 1 make appropriate call of setupdatecallback method * and pass exerciseupdatelistener object as an argument * 2 change ismeasurementrunning flag value to true **************************************************************************/ // exerciseclient setupdatecallback "todo 3 1 " ; log i tag, "successfully set update listener" ; // "todo 3 2 " } in the deadlift java file, call the startexercise method in onbuttonclickhelper public void onbuttonclickhelper { /******************************************************************************************* * [practice 2] start the exercise using a method from deadliftutil java * * - hint uncomment line below and fill todo 4 * call startexercise method on util object * ****************************************************************************************/ // "todo 4" } get the results go to the deadliftutil java file, and in the getnewrepsvalue method, call the getlatestmetrics method from the exerciseupdate class to get the data collected during the exercise store the data in the resultlist, where the last element holds the most up-to-date value of all your repetitions public long getnewrepsvalue exerciseupdate update, deltadatatype<long, intervaldatapoint<long>> datatype { /******************************************************************************************* * [practice 3] get the data collected during exercise * * - hint uncomment lines below and fill todo 5 * call getlatestmetrics method of exerciseupdate object * then, get the data of appropriate type * for this, you can use dedicated method getdata , passing datatype as an argument * ****************************************************************************************/ // final list<intervaldatapoint<long>> resultlist = "todo 5" // if !resultlist isempty { // final int lastindex = resultlist size - 1; // return resultlist get lastindex getvalue ; // } return no_new_value; } 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 instruction below on how to run unit tests right click on com samsung sdc21 deadlift test > deadliftunittest and execute run 'deadliftunittest' 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 actual deadlift parameters right after the app is started, it will request for the user permission allow the app to receive data of the activity afterwards, the application main screen will be shown before doing deadlifts, press the start button to track your exercise when done, tap on the stop button you're done! congratulations! you have successfully achieved the goal of this code lab now, you can create a deadlift exercise tracker app by yourself! if you're having trouble, you may download this file health track deadlift complete code 132 42 kb learn more by going to health platform
FAQ
docfaq q01 if i create a watch face using watch face studio, is it supported on all wear os watch devices? watch face studio is compatible with all wear os watch devices running api level 30 and higher if you create a watch face in watch face studio, you can use it on all wear os watch devices, regardless of manufacturer however, because of limitations with deprecated apis, your watch face may not be available on devices that are still using deprecated apis the galaxy watch studio serves tizen’s galaxy watch 1, 2, and 3 q02 does watch face studio support all types of watch face shapes, including circular and square? in watch face studio, the watch shape is set to a circle by default to support other watch face shapes, disable the apply circular crop option in the watch face canvas properties when circular crop is disabled, the watch face shape is determined by the user’s device to ensure watch face components display correctly, avoid placing components directly on the edges of the watch face the image can shift on some devices to prevent screen burn-in watch face studio creates a project with a single screen resolution, but the created watch face supports all device resolutions q03 how can i design my watch face to save battery? you can reduce battery usage through the following strategies use darker colors on the watch face make sure the images are fitted to the screen make sure you have removed all unused layers before building the watch face package for more information, see performance tips q04 how can i improve the performance of my watch face? using too many components in your watch face can degrade the performance of the watch face and consume the device battery more to optimize the use of components make sure fewer than 8 complications are visible in both ambient and normal modes make sure there are no hidden layers in either ambient or normal modes q05 how does my watch face work in always-on ambient mode? the second hand is not supported in ambient mode design your watch face to hide the second hand in ambient mode the on-pixel ratio opr varies between device models to find the opr for a specific device, check the device specification to examine the on-pixel performance of your design in ambient mode for various device shapes, in the run preview, select analyze you can also analyze the on-pixel performance for circular devices when you use the run on device and publish features in watch face studio q06 how can i enable users to customize their watch face? to enable watch face customization, define themes and styles for the watch face in the style property window the user can select from the themes and styles you have defined you can define a theme color palette and apply those colors to the component layers you can also implement multiple images for the analog hands, image, multimedia, and index components remember to give each component and style a clear, descriptive name the names appear when the user uses the customize mode to personalize their watch face you can also implement localized component names using text ids for more information, see project settings q07 what is the difference between the step counter tag expressions [sc], [sc_per], and [sc_goal]? the [sc] tag is the measured step count the [sc_goal] tag represents the step goal the user’s step goal can be synchronized from a supported health application, or you can define a step goal for the watch face to configure the step goal for your watch face, in wfs, go to file > project > settings > health the [sc_per] tag is the percentage of the step goal achieved, automatically calculated from the step count and step goal q08 how do i sell my watch face in a region that is not supported by the play store? watch faces can be sold in unsupported countries through the device manufacturer’s own app store for example, watch faces for galaxy watch can be sold through galaxy apps for more information, see galaxy store seller portal different app stores can support different file types for watch faces, such as apk or aab you must create the appropriate watch face package for each store q09 why can't i find the 'enable debugging over the bluetooth' setting in galaxy wearable application on my phone? check that your wearable device supports bluetooth debugging debug over bluetooth is not supported on wear 3 devices for more information, see debug over bluetooth q10 why can’t i use lottie multimedia files on my watch face anymore? lottie files are no longer supported since watch face studio version 1 4 13 you must replace them with animations in a supported format, such as webp or animated gif q11 how does the step goal "sync to device" feature work? the sync to device feature enables your watch face to use the step goal defined by the user on their device’s health application it is supported on watch devices running api level 33 and higher wear 4 and later on wear 3 devices, because sync to device is not supported, the step goal is fixed to 6000 if you want to set a different step goal for wear 3 devices, you must create a separate watch face version for wear 3, disable sync to device, and define the step goal directly q12 why are some heart rate tag expressions and features not supported for my watch face? some tag expressions and features related to measuring heart rate on wear os watch devices running api level 30 are not supported by watch face studio v1 4 13 however, wfs supports synchronizing the measured heart rate value with the value displayed on the screen on wear os watch devices running api level 33 and higher and galaxy watch devices for wear os powered by samsung, the open app feature supports opening the health application to view heart rate information on those devices q13 why can't i group a complication slot with other components or combine multiple complications? in watch face studio, complications must be implemented independently they cannot be grouped with or be part of another element complications can only contain elements within them
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
Learn Code Lab
codelabmeasure blood oxygen level 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 blood oxygen level spo2 measurement results 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 sample code 146 3 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 check capabilities for the device to track data with the samsung health sensor 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_on_demand ; } check connection error resolution using samsung health sensor sdk api, resolve any error when connecting to health tracking service 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 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_on_demand 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 health sensor sdk functionality * call gethealthtracker on healthtrackingservice object * use healthtrackertype spo2_on_demand 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 is completed, the listener has to be disconnected due to battery drain, on-demand measurement should not last more than 30 seconds the measurement is cancelled if the final value is not delivered in time note that the sensor needs a few seconds to warm up and provide correct values, which adds to the overall measurement time the blood oxygen level values come in the ondatareceived callback of trackereventlistener in spo2listener java file, you can see the code for 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 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 spo2tracking test and execute run 'tests in 'com samsung health spo2tracking'' 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 measure blood oxygen level 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 to get the blood oxygen level, 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 146 2 kb to learn more about samsung health, visit developer samsung com/health
Learn Code Lab
codelabmeasure skin temperature on galaxy watch objective create a health app for galaxy watch, operating on wear os powered by samsung, utilizing samsung health sensor sdk to obtain skin temperature measurement results 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 active 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 watch5 or newer with updated health platform 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! skin temperature tracking sample code 148 0 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, search for 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 and click open to open an existing project locate the downloaded android project skintemptracking from the directory and click ok check tracking capabilities to track the data with the sdk, the device must support skin temperature, like the galaxy watch5 skin temperature tracking can work in 2 modes batching and on-demand the tracker type for batching is healthtrackertype skin_temperature_continuous and healthtrackertype skin_temperature_on_demand for on-demand in this code lab, you are going to use on-demand tracker in connectionmanager java, navigate to isskintemperatureavailable function use a provided healthtrackingservice object to create a healthtrackercapability instance, and send it to checkavailabletrackers function, and assign its result to availabletrackers list gettrackingcapability returns a healthtrackercapability instance in 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 healthtrackertype list /****************************************************************************************** * [practice 1] check capabilities to confirm skin temperature availability * * ---------------------------------------------------------------------------------------- * * hint replace todo 1 with java code * get healthtrackercapability object from healthtrackingservice * send the object to checkavailabletrackers ******************************************************************************************/ boolean isskintemperatureavailable healthtrackingservice healthtrackingservice { if healthtrackingservice == null return false; @suppresswarnings "unusedassignment" list<healthtrackertype> availabletrackers = null; //"todo 1" if availabletrackers == null return false; else return availabletrackers contains healthtrackertype skin_temperature ; } initialization of skin temperature tracker before starting the measurement, initialize the skin temperature tracker by creating a healthtracker object in skintemperaturelistener java, navigate to setskintemperaturetracker using the provided healthtrackingservice object, create an instance of the healthtracker class of skin_temperature_on_demand type and assign it to the skintemperaturetracker object gethealthtracker with healthtrackertype skin_temperature_on_demand as an argument creates a healthtracker instance after a single measurement, the tracker should be stopped when using on-demand measurement for continuous measurement, use healthtrackertype skin_temperature_continuous healthtrackingservicehealthtrackingservice initiates a connection to samsung's health tracking service and provides a healthtracker instance to track a healthtrackertype healthtracker gethealthtracker healthtrackertype healthtrackertype create a healthtracker instance for the given healthtrackertype /******************************************************************************************* * [practice 2] setup skin temperature tracker * * ---------------------------------------------------------------------------------------- * * hint replace todo 2 with java code * initialize skintemperaturetracker with proper samsung health sensor sdk functionality * call gethealthtracker on healthtrackingservice object * use healthtrackertype skin_temperature_on_demand as an argument ******************************************************************************************/ void setskintemperaturetracker healthtrackingservice healthtrackingservice { //"todo 2" } starting and stopping the tracker for the client app to obtain the data through the sdk, set a listener method on healthtracker this method is called every time there is new data 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 the healthtracker instance void starttracker { if !ishandlerrunning { skintemperaturehandler post -> skintemperaturetracker seteventlistener skintemperaturelistener ; ishandlerrunning = true; } } after the finished measurement, the on-demand tracker should be stopped you can do that by unsetting the event listener from healthtracker 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 void stoptracker { if skintemperaturetracker != null skintemperaturetracker unseteventlistener ; skintemperaturehandler removecallbacksandmessages null ; ishandlerrunning = false; } process obtained skin temperature data the answer from the healthtrackingservice is asynchronous the skintemperaturelistener receives the callback containing a data point with all the required information follow the steps below to get skin temperature data in skintemperaturelistener java, go to the updateskintemperature function and read skin temperature data from datapoint get skin temperature status using datapoint api key valuekey skintemperatureset status get skin temperature value using datapoint api key valuekey skintemperatureset object_temperature get ambient temperature value using datapoint api key valuekey skintemperatureset ambient_temperature datapointdatapoint provides a map of valuekey and value with a timestamp public <t>t getvalue valuekey<t>type get data value for the given key private final healthtracker trackereventlistener skintemperaturelistener = new healthtracker trackereventlistener { @override public void ondatareceived @nonnull list<datapoint> list { stoptracker ; for datapoint data list { updateskintemperature data ; } } }; /******************************************************************************************* * [practice 3] read values from datapoint object * - get skin temperature status value * - get wrist skin temperature value - it's named "object_temperature" in the library * - get ambient temperature value ------------------------------------------------------------------------------------------- * - hint replace todo 3 with parts of code * 1 remove skintemperaturestatus invalid_measurement and * set status from 'datapoint' object using data getvalue valuekey skintemperatureset status * * if status is 'skintemperaturestatus successful_measurement' then * 2 set wristskintemperaturevalue from 'datapoint' object using * data getvalue valuekey skintemperatureset object_temperature ; * 3 set ambienttemperaturevalue from 'datapoint' object using * data getvalue valuekey skintemperatureset ambient_temperature ; ******************************************************************************************/ void updateskintemperature datapoint data { final int status = skintemperaturestatus invalid_measurement; float wristskintemperaturevalue = 0; float ambienttemperaturevalue = 0; //"todo 3" trackerdatasubject notifyskintemperaturetrackerobservers status, ambienttemperaturevalue, wristskintemperaturevalue ; } 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 the instruction below on how to run unit tests right click on com samsung health skintemptracking test and execute run 'tests in 'com samsung health skintemptrackin" command if you have completed all the tasks correctly, you can see all the unit tests pass successfully run the app after building the apk, you can run the application on a connected device to measure your skin temperature once the app starts, allow the app to receive data from the body sensors afterwards, the screen shows the application tap the measure button to get your skin temperature to stop measuring, 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 skin temperature by yourself! if you are having trouble, you may download this file skin temperature tracking complete project 147 8 kb to learn more about samsung health, visit developer samsung com/health
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
Develop Galaxy Watch for Tizen
doccreate your first tizen wearable native watch application welcome to tizen wearable native watch application development! note for watch face developers you can create watch faces with galaxy watch studio or tizen studio for your personal enjoyment however you will not be able to add watch face applications to seller portal until you have received approval to publish watch faces the review is not required for watch app and widget developers galaxy store supports watch faces for galaxy watch3 and earlier samsung watches running on tizen watch faces for galaxy watch4 and later running on wear os powered by samsung is only supported in the chinese galaxy store a wearable native watch application is created using the c language, and can be run on tizen wearable devices to display a customized watch face to the user study the following instructions to help familiarize yourself with the tizen native application development process as well as using the tizen studio and installing the created application on the emulator or target device with the instructions, you can create and run a basic wearable native watch application, which displays some text and the current time on the screen before you get started with developing tizen applications, download and install the tizen studio for more information on the installation process, see the installation guide create a wearable native watch project using the tizen studio this step shows how you can use a predesigned project template that creates all the basic files and folders required for your project build the application after you have implemented code for the features you want, this step shows how you can build the application to validate and compile the code run the application this step shows how you can run the application on the emulator or a real target device design a ui this step shows how you can create the application ui and make small alterations to it to improve the usability of your application when you are developing a more complex application, you can take advantage of the native tools included in the tizen studio to ease the tasks of creating functionality and designing the application ui creating a project the following example shows you how to create and configure a basic wearable native watch application project in the tizen studio an application project contains all the files that make up an application the following figure illustrates the application to be created the application screen displays the hello watch text and the current time, which continues to be refreshed every second while the application runs figure wearable native watch application to create the application project launch the tizen studio in the tizen studio menu, select file > new > tizen project the project wizard opens in the project wizard, define the project details the project wizard is used to create the basic application skeleton with the required folder structure and mandatory files you can easily create different applications by selecting an applicable template or sample for the project wizard to use select the template project type and click next select the profile wearable and version from a drop-down list and click next the version depends on the platform version you have installed and with which you are developing the application select the native application application type and click next select the watch template and click next define the project properties and click finish you can enter the project name 3-50 characters and the unique package id you can also select the location and working sets by clicking more properties the project wizard sets up the project, creates the application files using the default content from the template, and closes for more information on the project wizard and the available templates, see creating tizen projects with tizen project wizard you can see the created project in the project explorer view the most important files and folders include inc default folder for included source files res folder for resource files used by the application only shared folder for resource files to be shared with other applications src folder for source code files lib folder for external library files tizen-manifest xml manifest file used by the platform to install and launch the application figure application in the project explorer note you can view and modify the application configuration in the manifest editor in this example, no configuration changes are required your application project is now ready for further actions next, build the application managing the application configuration to view and modify the application configuration in the project explorer view, double-click the tizen-manifest xml file of the application the tizen studio opens the file in the manifest editor in the manifest editor, view and modify the configuration details using the various tabs overview define general information, such as the package, label, and icon of the application features define required software and hardware features this information is used for application filtering in the tizen store privileges define the security-sensitive apis or api groups accessed and used by the application localization define localized values for the application label, description, and icon advanced define advanced features, such as application metadata and some miscellaneous options source view and edit the source code of the tizen-manifest xml file changes made and saved on the other tabs are reflected in the source code and vice versa note the tizen-manifest xml file must conform to both the xml file format and the tizen native application specification requirements editing the file in the source tab is intended for advanced users only to save any changes, in the tizen studio menu, select file > save all for more information on configuring the application, see setting the application manifest understanding the source code pay attention to the following main issues in the application source code in the inc/watch h and src/watch c files , to understand how the application is designed and how it works for source code details related to the ui, see designing a simple ui the watch application is initialized to use the functions and data types of the watch application api by including the <watch_app h> header file in your application #include <watch_app h> all header files that you need are already included in the watch h file, which is generated by the tizen studio when the template project is created the life-cycle callbacks manage specific parts of the application life-cycle they are set in the watch_app_lifecycle_callback_s structure, and the structure is passed to the watch_app_main function of the watch application api to start the watch application event loop int main int argc, char *argv[] { appdata_s ad = {0,}; int ret = 0; watch_app_lifecycle_callback_s event_callback = {0,}; app_event_handler_h handlers[5] = {null,}; event_callback create = app_create; event_callback terminate = app_terminate; event_callback pause = app_pause; event_callback resume = app_resume; event_callback app_control = app_control; event_callback time_tick = app_time_tick; event_callback ambient_tick = app_ambient_tick; event_callback ambient_changed = app_ambient_changed; ret = watch_app_main argc, argv, &event_callback, &ad ; if ret != app_error_none dlog_print dlog_error, log_tag, "watch_app_main is failed err = %d", ret ; return ret; } the create event is triggered before the application main loop starts in this callback, you can initialize the application resources, such as create windows and data structures static bool app_create int width, int height, void *data { /* hook to take necessary actions before the main event loop starts initialize ui resources and application's data if this function returns true, the main loop of application starts if this function returns false, the application is terminated */ appdata_s *ad = data; create_base_gui ad, width, height ; return true; } the time_tick event is triggered at least once per second the watch applications can get the current time from the watch_time time handle to draw a normal watch static void app_time_tick watch_time_h watch_time, void *data { /* called each second while your app is visible; update the watch ui */ appdata_s *ad = data; update_watch ad, watch_time, 0 ; } note for more information on the application life-cycle callbacks, see applications an ambient mode is available on a low-powered wearable device in this mode, the watch application shows a limited ui and receives only the ambient tick event every minute to reduce power consumption the details of the limited ui drawn in the ambient mode depend on the device in addition, due to the ambient mode being a low power mode, there are limits to the colors that can be shown on the screen usually, when designing the ambient mode ui, draw it with limited colors cyan, magenta, yellow, red, green, blue, black and white , and use less than 15% of the pixels on the screen if you do not want to draw your own ambient mode ui, set the ambient-support attribute to false in the watch application manifest file to allow the platform to show a default ambient mode ui note to use the ambient mode, the user must enable it in the device settings in addition, on the galaxy watch device, the ambient mode activates only when you are wearing the watch on the wrist - the `ambient_tick` callback is triggered every minute while the device is in the ambient mode you can use the callback to update the time on your watch application in the ambient mode in this callback, do not perform time-consuming tasks and always update the ui as quickly as possible the platform can put the device to sleep shortly after the ambient tick expires ```c static void app_ambient_tick watch_time_h watch_time, void *data { /* called at each minute while the device is in ambient mode update watch ui */ appdata_s *ad = data; update_watch ad, watch_time, 1 ; } ``` - the `ambient_changed` callback is triggered when the ambient mode is enabled or disabled on the device you can use the callback to initialize your ambient mode ui ```c static void app_ambient_changed bool ambient_mode, void *data { if ambient_mode /* prepare to enter the ambient mode */ else /* prepare to exit the ambient mode */ } ``` building your application after you have created the application project, you can implement the required features in this example, only the default features from the project template are used, and no code changes are required when your application code is ready, you must build the application the building process performs a validation check and compiles your files you can build the application in the following ways automatically the automatic build means that the tizen studio automatically rebuilds the application whenever you change a source or resource file and save the application project to use the automatic build select the project in the project explorer view in the tizen studio menu, select project > build automatically a check mark appears next to the menu option you can toggle the automatic build on and off by reselecting project > build automatically manually the manual build means that you determine yourself when the application is built to manually build the application, right-click the project in the project explorer view and select build project figure manually building the application alternatively, you can also select the project in the project explorer view and do one of the following in the tizen studio menu, select project > build project press the f10 key you can have more than one build configuration to see the current active configuration or change it, right-click the project in the project explorer view and select build configurations > set active the default configuration is debug for more information, see building applications after you have built the application, run it running your application you can run the application on the emulator or a real target device running on the emulator to run the application on the emulator launch an emulator instance in the emulator manager in the tizen studio menu, select tools > emulator manager in the emulator manager, select a wearable emulator from the list and click launch if no applicable emulator instance exists, create a new one the emulator is launched in its own window you can also see the new emulator instance and its folder structure in the device manager generate a security profile before you run the application, you must sign your application package with a certificate profile in the tizen studio run the application in the project explorer view, right-click the project and select run as > tizen native application alternatively, you can also select the project in the project explorer view and do one of the following press the ctrl + f11 key click the run icon in the toolbar if you have created multiple emulator instances, select the instance you want from the combo box in the toolbar before selecting to run the application if you select an offline emulator, it is automatically launched when you select to run the application confirm that the application launches on the emulator note if the emulator display has switched off, you cannot see the application launch to switch the display on, click the power key in the lower-right corner of the emulator 3 change the watch face <a name="watchface"></a> to change the watch face and make the installed watch application visible ![changing the watch face] https //docs tizen org/application/native/get-started/wearable-watch/media/watch_run_change_wn png 1 if the emulator display has been switched off, activate it by pressing the **power** key in the lower-right corner of the emulator 2 on the home screen showing the default watch face , press the **power** key 3 in the recent apps screen, select **settings \> watch faces and styles \> watch faces** 4 swipe right until you find your application icon, and select it the **clock changed** message is displayed 5 press the **back** key in the upper-right corner of the emulator device multiple times, until the home screen with your new watch face is shown ![application running in the emulator] https //docs tizen org/application/native/get-started/wearable-watch/media/watch_run_face_wn png while the application is running, the **log** view in the tizen studio shows the log, debug, and exception messages from the methods defined in the log macros to see the view, in the tizen studio menu, go to **window \> show view \> log** for more information on using the emulator features, see using emulator control keys, menu, and panel and using extended emulator features running on a target device to run the application on a target device connect the wearable target device to your computer define settings on the device go to settings > connections, and switch on wi-fi the device and the computer must be connected to the same wi-fi network note the ip address the device is using go to settings > gear info, and switch on the debugging mode in the terminal, enter the following commands cd tizen-studio/tools /sdb connect <ip address of galaxy watch> use the ip address you noted before instead of the terminal, you can also use the remote device manager for the connection in the first attempt, the connection fails and the device asks for user confirmation to allow galaxy watch to read log data, copy files to and from your computer, and install the application manually, click the accept mark in the device manager, confirm that the device is connected shown in the device list generate an author certificate before you run the application, you must sign your application package with a certificate profile in the tizen studio run the application in the device manager, select the device in project explorer view, right-click the project and select run as > tizen native application alternatively, you can also select the project in the project explorer view and do one of the following press the ctrl + f11 key click the run icon in the toolbar if you have both a connected device and existing emulator instances, select the device from the combo box in the toolbar before selecting to run the application confirm that the application launches on the target device like with the emulator, you can change the watch face in the device settings to see the watch application on the home screen note the application is launched using the default debug run configuration to create and use another configuration in the project explorer view, right-click the project and select run as > run configurations in the run configurations window, click the new launch configuration icon , define the configuration details, and launch the application by clicking run designing a simple ui the wearable watch application created with the watch template has a simple user interface with a label component showing the hello watch text and the current time hour, minute, and second the ui is created using efl in the ambient mode, the watch template ui is identical to the normal ui, except that is shows the current time without the seconds figure user interface in the watch template ambient mode on the right creating the basic ui the ui in the watch template contains the following components the efl ui always contains a window component, which is the root component of the entire ui the application uses the conformant component as a container for other ui components the label showing the hello watch text and the current time is implemented with a label component the ui is created in the watch c file data structure a pointer to the ui components is stored in the appdata_s data structure struct appdata { /* window */ evas_object *win; /* conformant */ evas_object *conform; /* label */ evas_object *label; }; typedef struct appdata appdata_s; ui creation the app_create life-cycle callback is called when the application main loop starts, and it calls the create_base_gui function to create the ui static bool app_create int width, int height, void *data { /* define system callbacks */ appdata_s *ad = data; create_base_gui ad, width, height ; return true; } ui components the create_base_gui function creates the ui components window, conformant, and label the function receives a pointer to fill in the appdata_s structure static void create_base_gui appdata_s *ad, int width, int height { the window object of the idle screen is retrieved with the watch_app_get_elm_win function of the watch application api the watch_time_h handle is created for managing the current time, and the evas_object_resize function is used to resize the window to fit the screen int ret; watch_time_h watch_time = null; ret = watch_app_get_elm_win &ad->win ; if ret != app_error_none { dlog_print dlog_error, log_tag, "failed to get window err = %d", ret ; return; } evas_object_resize ad->win, width, height ; the conformant component is used as a container for the other ui components the component is the first object added inside the window with the elm_conformant_add function the conformant component is set as a resize object of the window by using the elm_win_resize_object_add function it means that the conformant size and position are controlled by the window component directly the evas_object_show function makes the conformant component visible ad->conform = elm_conformant_add ad->win ; evas_object_size_hint_weight_set ad->conform, evas_hint_expand, evas_hint_expand ; elm_win_resize_object_add ad->win, ad->conform ; evas_object_show ad->conform ; the label component for the text and time is added with the elm_label_add function the label is added inside the conformant component, which is the label's parent the label is resized and moved so that it is located below the first third of the screen height ad->label = elm_label_add ad->conform ; evas_object_resize ad->label, width, height / 3 ; evas_object_move ad->label, 0, height / 3 ; evas_object_show ad->label ; the watch_time_get_current_time function retrieves the current time, and the update_watch function uses the current time to set the label component content finally, the watch_time_h handle is deleted ret = watch_time_get_current_time &watch_time ; if ret != app_error_none dlog_print dlog_error, log_tag, "failed to get current time err = %d", ret ; update_watch ad, watch_time, 0 ; watch_time_delete watch_time ; when all the ui components are ready, the evas_object_show function makes the window component visible this means that the window displays everything on the screen at once evas_object_show ad->win ; } modifying existing components when the basic ui exists, you can easily modify the components in the ui by using the component-specific functions, or more general evas object functions for example, the following modification to the label component changes the text color to red ad->label = elm_label_add ad->conform ; evas_object_color_set ad->label, 255, 0, 0, 255 ; evas_object_resize ad->label, width, height / 3 ; evas_object_move ad->label, 0, height / 3 ; evas_object_show ad->label ; figure modified label component showing the current time you can update the time on the screen with the time_tick in the normal mode or ambient_tick in the ambient mode callback both callbacks contain the current time handle, and call the update_watch function to update the label content on the screen static void app_time_tick watch_time_h watch_time, void *data { appdata_s *ad = data; update_watch ad, watch_time, 0 ; } static void app_ambient_tick watch_time_h watch_time, void *data { appdata_s *ad = data; update_watch ad, watch_time, 1 ; } in the update_watch function, the watch_time_h handle is used to retrieve the current time elements hour, minute, and second with the watch_time_get_hour24 , watch_time_get_minute , and watch_time_get_second functions of the watch application api the text for the label component is defined based on whether the normal or ambient mode is used , and set with the elm_object_text_set function static bool update_watch appdata_s *ad, watch_time_h watch_time, int ambient { char watch_text[text_buf_size]; int hour24; int minute; int second; if watch_time == null return; watch_time_get_hour24 watch_time, &hour24 ; watch_time_get_minute watch_time, &minute ; watch_time_get_second watch_time, &second ; if !ambient { snprintf watch_text, text_buf_size, "<align=center>hello watch<br/>%02d %02d %02d</align>", hour24, minute, second ; } else { snprintf watch_text, text_buf_size, "<align=center>hello watch<br/>%02d %02d</align>", hour24, minute ; } elm_object_text_set ad->label, watch_text ; }
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.