Filter
-
Content Type
-
Category
Mobile/Wearable
Visual Display
Digital Appliance
Platform
Recommendations
Filter
Learn Code Lab
codelabdesign a watch face using mask and moon phase tags objective design a watch face that shows the eight phases of the moon using the mask feature and moon phase tags in watch face studio overview watch face studio is a graphical authoring tool that enables you to design watch faces for the wear os smartwatch ecosystem, including galaxy watch4 and newer versions it provides easy and simple features, such as masking and tag expression, for creating attractive and dynamic watch faces without coding masking is the technique of hiding or revealing parts of a layer based on the shape outline of the bottom layer you can use it to enhance visual impact, create special effects, or draw focus to specific areas of an image tag expressions are conditions in watch face studio that let you dynamically configure the movement and data of a watch face what is moon phase? the moon completes its orbit for approximately 28 days, undergoing a singular lunar cycle from new moon to new moon this lunar cycle is divided into eight distinct phases with 28 positions the visible appearance of the moon, as observed from earth, is referred to as its phase moon phase position days type of moon phase 0~0 5 new moon 0 5~0 65 evening crescent 7 first quarter 7 5~13 5 waxing gibbous 14 full moon 14 5~20 5 waning gibbous 21 last quarter 21 5~27 5 morning crescent 27 5~28 new moon set up your environment you will need the following watch face studio galaxy watch4 or newer smart watch running on wear os3 or higher sample project here is a sample project for this code lab download it and start your learning experience! moon phase sample project 1 41 mb start your project download the sample project file, and click open project in watch face studio locate the downloaded file, then click open show grid, coordinate axis and rulers to set the different positions of the moon accurately and easily, you can utilize the coordinate system of the watch face studio select the show grid, show coordinate axis, and show rulers options from the view menu it will display a grid on the canvas, the x and y axis, and rulers for precise measurement and placement of components the center placement of the entire watch face is 225,225 noteyou can change the grid's color from the preferences > view create two mask groups when you mask two or more images, the shape of the bottom-most layer determines the visible area of the mask group the layers above it appear only through the shape outline of the bottom layer for example, if you place a square image on the bottom layer and an image in the layer above it, the image appears only through the square outline of the bottom layer the sample project consists of two similar images of the moon moon_qgf and moon_nc and two different shapes as bottom layers moon_qgf_layer and moon_nc_layer using these components, create two mask groups to use for simulating eight major moon phases select moon_qgf and moon_qgf_layer images and click mask rename the mask group as moon_qgf_mask it will cover five moon phases the first quarter, waxing gibbous, full moon, waning gibbous, and last quarter do the same for moon_nc and moon_nc_layer to cover the remaining moon phases the new moon, evening crescent, and morning crescent rename the mask group as moon_nc_mask tipread use masks to get creative with watch faces to explore other possibilities of masking add tag expressions to simulate different moon phases watch face studio provides tags to determine the moon phase's type moon_ty and position moon_po the corresponding tag values per moon phase are listed in the table below moon phase [moon_ty] values [moon_po] values new moon 0 0~0 5 evening crescent 1 0 5~0 65 first quarter 2 7 waxing gibbous 3 7 5~13 5 full moon 4 14 waning gibbous 5 14 5~20 5 last quarter 6 21 morning crescent 7 21 5~27 5 new moon 0 27 5~28 using tag expressions, adjust the properties of each mask group and its bottom-most layer to dynamically show each moon phase in different placements you can lay out the moon phases as below gibbous, quarter, and full moon the moon_qgf_mask currently displays the full moon, and its placement coordinate is 195, 23 use the grid lines and rulers to determine the placement of the other four moon phases the first quarter, waxing gibbous, waning gibbous, and last quarter add tag expressions to the placement x and y and color properties of moon_qgf_mask placement - x coordinate move the mask group to the left of the full moon for the first quarter and waxing gibbous and to the right for the waning gibbous and last quarter replace each x with the distance in pixels between the x-placement of the full moon and the preferred x-placement of the other four moon phases [moon_ty] == 2 ? -x [moon_ty] == 3 ? -x [moon_ty] == 5 ? + x [moon_ty] == 6 ? + x 0 placement - y coordinate move the mask group down replace each y with the distance between the y-placement of the full moon and the preferred y-placement of the other four moon phases [moon_ty] == 2 ? + y [moon_ty] == 3 ? + y [moon_ty] == 5 ? + y [moon_ty] == 6 ? + y 0 color - opacity show moon_qgf_mask only if the mask group covers the current moon phase otherwise, hide it [moon_ty] ==2 + [moon_ty] ==3 + [moon_ty] ==4 + [moon_ty] ==5 + [moon_ty] ==6 ?0 -100 change the moon's appearance by adjusting the dimension and image placement of moon_qgf_layer using tag expressions placement - x coordinate move the image to the right of the moon image for the first quarter and waxing gibbous and to the right for the waning gibbous and last quarter replace each x with the length of the portion to hide if the moon image is 50px and the quarter moon shows only half of it, then the portion to hide is ~25px [moon_ty] == 2 ? +x [moon_ty] == 3 ? +x [moon_ty] == 5 ? -x [moon_ty] == 6 ? - x 0 placement - y coordinate move the image up for the first and last quarter [moon_ty] == 2 ? -y [moon_ty] == 6 ? -y 0 dimension - height for the first and last quarter, adjust the height h to transform the image from a circle to an oval shape to simulate the appearance of a quarter moon [moon_ty] ==2 ? h [moon_ty] ==6 ? h 0 crescent and new moon the moon_nc_mask currently displays the evening crescent, and its placement coordinate is 6, 110 changing its placement and dimension properties can show the rest of the moon phases the morning crescent and the new moon similarly, add tag expressions to the properties of moon_nc_mask placement - x coordinate move the mask group slightly to the left of the evening crescent when the new moon's position is 0 5 or less otherwise, move the mask group to the opposite side of the watch face; the same for the morning crescent replace each x with the distance between the x-placement of the evening crescent and the preferred x-placement of the other moon phases [moon_ty] == 0 ? [moon_po] <= 0 5 ? -x +x [moon_ty] == 7 ? +x 0 placement - y coordinate move the mask group down for the new moon replace y with the distance between the y-placement of the evening crescent and the preferred y-placement of the new moon [moon_ty] == 0 ? +y 0 color - opacity show moon_nc_mask only if the mask group covers the current moon phase otherwise, hide it [moon_ty] ==0 + [moon_ty] ==1 + [moon_ty] ==7 ?0 -100 change the moon's appearance by adjusting the image placement of moon_nc_layer using tag expressions placement - x coordinate move the image slightly to the right of the moon image when the new moon's position is 0 5 or less otherwise, move the image to the left replace each y with the distance between the initial x-placement of the layer and the preferred x-placement; to hide portions of the moon image to simulate the appearance of the other moon phases [moon_ty] == 0 ? [moon_po] <= 0 5 ? +y -y [moon_ty] == 7 ? -y 0 test the watch face in the run pane, click the preview watch face icon adjust the date to see the moon change from one phase to another you can check for a complete lunar cycle from 18 july 2023 to 16 august 2023 to test your watch face on a smart watch, you need to connect a watch device to the same network as your computer in watch face studio, select run on device select the connected watch device you want to test with if your device is not detected automatically, click scan devices to detect your device or enter its ip address manually by clicking the + button notethe always-on display is already set in the project to run the watch face successfully, you may need to configure its always-on display to avoid any error when you run on device you're done! congratulations! you have successfully achieved the goal of this code lab now, you can use mask and moon phase tags for making a dynamic watch face in watch face studio all by yourself! if you're having trouble, you may download this file moon phase complete project 1 87 mb to learn more about watch face studio, visit developer samsung com/watch-face-studio
Learn Developers Podcast
docseason 2, episode 7 previous episode | episode index | next episode this is a transcript of one episode of the samsung developers podcast, hosted by and produced by tony morelan a listing of all podcast transcripts can be found here host tony morelan senior developer evangelist, samsung developers instagram - twitter - linkedin guests eric cloninger, lead, developer relations team, samsung electronics chris shomo, infinity watchfaces listen download this episode topics covered sdc21, virtual conference history of the samsung developer conference conference audience keynote speakers conference announcements technical sessions expo floor galaxy store gallery code lab virtual reality after-hours party chris shomo, infinity watchfaces watch face studio 2020 best of galaxy store awards 2021 best of galaxy store awards bixby developers one ui beta samsung podcast platform smartthings helpful links sdc21, virtual conference - developer samsung com/sdc sdc18 highlights - youtube video sdc19 highlights - youtube video sdc19 replay - youtube video sdc21 preview - youtube video code lab - developer samsung com/codelab chris shomo, infinity watchfaces - youtube video watch face studio - developer samsung com/one-ui-watch 2020 best of galaxy store awards - youtube video 2021 best of galaxy store awards preview - youtube video bixby developers - bixbydevelopers com/ one ui beta - developer samsung com/one-ui-beta/index html samsung podcast platform - samsungpodcasts com/ smartthings - developer samsung com/smartthings samsung developers homepage - developer samsung com samsung developers newsletter - developer samsung com/newsletter samsung developers blog - developer samsung com/blog samsung developers news - developer samsung com/news samsung developers facebook - facebook com/samsungdev samsung developers instagram - instagram com/samsung_dev samsung developers twitter - twitter com/samsung_dev samsung developers youtube - youtube com/samsungdevelopers samsung developers linkedin - linkedin com/company/samsungdevelopers eric cloninger linkedin - linkedin com/in/ericcloninger/ chris shomo linkedin - linkedin com/in/christopher-shomo tony morelan linkedin - linkedin com/in/tony-morelan transcript note transcripts are provided by an automated service and reviewed by the samsung developers web team inaccuracies from the transcription process do occur, so please refer to the audio if you are in doubt about the transcript tony morelan 00 01 hey, i'm tony morelan and this is pow! the samsung developers podcast where we chat with innovators using samsung technologies, award winning app developers and designers, as well as insiders working on the latest samsung tools welcome to season two, episode seven today's show is a special episode of the pow! podcast last year, we were not able to have our annual samsung developer conference because of the pandemic but this year, we're back with sdc21, a virtual conference this coming october, i sat down with eric cloninger, who leads developer relations at samsung not only do we talk about some of the highlights from our past developer conferences, but what you can look forward to at this year's sdc21 enjoy hey, eric, welcome to the podcast eric cloninger 00 51 hey, tony glad to be here tony morelan 00 53 so i couldn't be more excited about this special episode where we get to chat about not only the past samsung developer conferences, but our upcoming sdc21 eric cloninger 01 03 yeah, it's gonna be a lot of fun it is different this year for certain tony morelan 01 06 let me first start off by asking what exactly is the samsung developer conference, eric cloninger 01 11 samsung creates a lot of different platforms and sdks for developers to create for and integrate with so sdc is one of the ways we promote our platforms, and educate developers on their capabilities like many companies, we realized that developers add a lot of value to our products with their own creations so sdc is our opportunity to share knowledge and hopefully build a connection to the people that are making our products better tony morelan 01 36 yeah, and what's unique with sdc 21 is this year, it's actually going to be a virtual conference now we know that it's because the current pandemic we're in, but it's, i think, an opportunity for samsung really to reach to a much bigger global audience that will be able to come in and attend our conference eric cloninger 01 55 certainly, you know, in the years past, it's been a live event and there would be quite a few people there -- several thousand now with it being virtual, we have a much bigger audience and people can actually see the technical sessions as well as the keynote online even though it's not in person, it is still something that where we can share knowledge, and people can give us feedback on what they like and don't tony morelan 02 21 let's go back and talk a little bit about the history of sdc i think it started back in 2013 is that correct? that's correct eric cloninger 02 29 and i was there in 2014, talking about the gear watch tony morelan 02 34 development wow, that must have been pretty close to when we first launched the watch eric cloninger 02 39 i think it was the first gear s was the product that that i was working on and we were talking about development tools and how to write apps for those watches tony morelan 02 49 since then, we've done seven sdcs that, you know, there was a year i think around 2015 that we skipped and of course last year, we did have to hold off on doing an actual conference past locations, primarily san francisco in the bay area eric cloninger 03 06 it's been at moscone every year until 2019, when it moved to san jose so it's always been in the bay area somewhere that people who attend tony morelan 03 15 tell me about, you know, what is what is the audience eric cloninger 03 19 the audience is primarily developers and the content is really focused on that group a lot of samsung employees attend to give the technical talks and a lot to people come from all over the world to work in the booths and on the show floor in one sense sdc is like a family reunion, we get a chance to meet the people that we've emailed with and been on web conferences for a long time that's a chance to come together but it's also the fruition of a year of hard work, you'll whether it's virtual or in person, we can use the opportunity to celebrate and to share what we've worked on with third party developer community tony morelan 04 05 yeah, i know, my first sdc was 2018 that was in san francisco i hit started at samsung just a few months earlier than that so it was a great opportunity, really, for me to meet, not just some of these employees that had only been, you know, emailing with but a lot of the partners that we had a great report with sdc 19 eric cloninger 04 29 i think there was over 5000 close to 6000 people that it's been five to 6000 every year since that i've been here yeah, so that's a fairly good-sized conference tony morelan 04 37 so let's talk about some of the past keynotes and some of the big announcements that we've made going back to 2017 i think we had stan lee, is that correct? eric cloninger 04 47 yeah, stan lee from marvel was one of the main speakers that was pretty interesting in 2018, we had a lot of people watching because that's the day that they announced the galaxy fold wow so the first time anybody saw it was on stage at sdc and there were probably a half a million people watching live on either facebook live or youtube tony morelan 05 13 i remember my takeaway from sdc18 was tim sweeney for fortnite epic games? eric cloninger 05 18 absolutely on stage with one of our vps who was holding your tiny sword and shield you know, it just it added to the silliness, but also the fun was pretty, pretty fun tony morelan 05 33 oh, definitely now sdc 19 we had another very interesting person up on the stage talk a little bit about vitalik eric cloninger 05 41 yeah, vitalik buterin is the co-founder of ethereum and that year, we also had justin sun from tron the blockchain community is very interesting and it's definitely a new aspect for samsung is we had the blockchain wallet sdk that was coming out that year and so we wanted to have people that could talk about their interactions with it so vitalik and justin, were on stage in the spotlight session on day two tony morelan 06 09 yeah, that was pretty exciting actually, to see him up on stage they're in live in person so a big part of our conference are the technical sessions, it's a chance for the community really to learn about new and upcoming technologies talk a bit about some of those sessions that we've had in the past eric cloninger 06 27 so pretty much any of samsung's technical features sdks and services have sessions at sdc so if you're interested in ai and voice activated services, you can go to multiple bixby sessions, if you're into the internet of things and how to integrate into samsung smartthings ecosystem, there will be information there you know, as i mentioned previously, there's blockchain, there's the knox partnership for if you want to do secure computing, one ui if you're a designer, and all the new foldable phones and devices out there, there's a lot of content around how to handle app continuity and the flex mode, as well as the unique things about foldable design that you can learn about, as well as things like samsung health and how to design for themes there's a wide range of technical sessions for pretty much anybody at any experience level tony morelan 07 24 yeah, yeah, in my area of involvement with the developer conference has been around that design side i mean, as you know, my background is in design, you know, when we are giving the sessions on theme, designing watchface designing that that's really where i get my involvement with so a lot of fun for me to be at the conference walking around the expo floor has been one of the most exciting things for me to be there because truthfully at these different conferences, you just don't know what you're going to see and i remember walking in the room if it was sdc 18 or 19 but seeing this awesome car on the expo floor, the harmon car eric cloninger 08 00 yeah, the great thing about the expo floor is where you, you get to do a lot of the kind of non-technical learning it's a great place in a more relaxed atmosphere to meet and talk to people about what's going on so the harmon car harman is a subsidiary of samsung, and they create high end audio equipment so i'm sure you're familiar with brands like harman, kardon, or jbl, or infiniti, all very high-end brands harman also creates infotainment systems and telematics solutions for automakers and so what they would do for several years is they would bring a car onto the show floor and deck it out with a lot of the latest software and hardware, as well as the audio systems for the attendees to sit in the car and try it out unfortunately, they wouldn't let us drive it around the show floor obviously tony morelan 08 47 i will say i actually did ride the elevator with the person who drove the car from southern california up to northern california for the show so i did get to ask a little bit about you know what it is like to get behind the wheel of that car and she said it was an absolute blast to drive it up five eric cloninger 09 04 i'm sure they had to go the speed limit though tony morelan 09 06 definitely i know that smart things back in 14, one of our first conferences they actually set up like what they call the connected home eric cloninger 09 14 yeah, it was actually a full size when not full sizes about a 900 square foot, you know, a 30 by 30 area where they had different rooms and inside each of those rooms, they would have different ways that you could integrate different iot solutions into the smart home tony morelan 09 32 now just to be clear, a 900 square foot home in san francisco actually is full size so in 2018, we did something i was actually pretty excited about we created what we called a gallery of theme so you know as you know, with the galaxy store, designers can publish their phone themes, but what we did is we took those designs and actually built like a museum gallery big, full size images of the different themes nicely framed, and people would walk around this gallery and not only see this beautiful, much larger than life theme design but this was a gallery where at the end of the conference, we actually raffled off the different pieces, eric cloninger 10 15 it really shows how we have a lot of incredibly creative people who are creating work for the galaxy store, and samsung galaxy devices all of those things that were shown in that that gallery are available for anyone to download and purchase on the galaxy store tony morelan 10 31 yeah, i know that that gallery really, really was a success in a lot of people really enjoyed seeing that worked in person another area of the floor that i saw had a lot of activity was code lab, talking about what exactly is code lab at the at the conference eric cloninger 10 46 code lab is an interactive learning experience, you don't have to actually be present at sdc to be able to use it samsung employees create guided learning modules, with examples and downloadable code snippets that you can use to learn anything from android development, watch face design, or theme by the time you've gone through everything tony morelan 11 13 so if people want to learn more about code lab outside of the conference, where can they find that information, eric cloninger 11 18 you can find the code lab on the samsung developer portal at developer samsung com/codelab tony morelan 11 26 so i think one of the most exciting things that i saw happen on the expo floor was the vr team, they set up this like photography studio that talk about that eric cloninger 11 36 so in 2018, that team created what was called a volumetric camera setup so it had cameras in a lot of different positions in 360 degrees so they would take a very detailed scan of your body, and then they would print it out on a 3d printer and so that was really cool and then the following year, that same team took that that same type of technology, and they integrated it with a live interactive experience called delusion and delusion was a very creepy, interactive experience where you interacted with all of these crazy characters and because of the time of the year, it was october 29, and 30th so it's just the day before halloween, okay, you had all of these various characters that you were interacting with in a 3d experience and the thing that was cool about it was the second night, we had this, you know, after hours segment and those characters in the game that actually came to life, and you actually saw these people walking around that you had interacted with, in the interactive exhibit tony morelan 12 49 yeah, i remember that being a very fun and freaky evening, i was i was working in one of the booths behind the scenes doors were closed and as they were prepping for the opening of the of the doors, the fog machine was rolling, that people started rushing in and then i saw those characters that had been in that interactive space, actually walking amongst the people and there were a few times that in a fun way, those a little not at ease with them with those different folks eric cloninger 13 23 yeah, it was kind of a creepy experience because some of those characters, i mean, they stayed in character, and they got to look right through you and it just it was very creepy experience so the after-hours is a lot of fun at you at sdc as it is, with a lot of events, it's an it's an opportunity to kind of be a lot more relaxed you'll see some people that you saw in the, the technical sessions earlier in the day, and you have a chance to maybe drill down a little deeper while you have, you know, a plate of food and beverage in your hand so it's a good experience overall and you know, to be honest, i'm looking forward to when we can do that again tony morelan 14 02 yeah, yeah, hopefully, hopefully that will be next year so i thought it would be nice if we brought in a designer slash developer who has been very involved with the samson community and who has not only attended and many of the past sdc conferences, but was also invited to speak at one of the past sessions chris shomo, from infinity watchfaces eric cloninger 14 20 hey, chris, welcome to the show chris shomo 14 23 hey, thank you for having me on here tony morelan 14 25 yeah, no, it's great it's great to have you on the podcast so looking back at the samsung developer program, chris has been one of those resources that we've turned to many times and it simply comes down to not only your success, but your willingness to share and, and really help grow the entire ecosystem for samsung watchfaces and galaxy devices chris shomo 14 43 well, one thing that i've learned is all about the community that's one of the reasons i love to share things that i find out because i've also reached out to other designers and ask them, you know, hey, how do you do this? how do you do that? and they're more than willing to share back so it really is a given take type of thing and you know, if you're nice, then you can find some answers that you're looking for out there tony morelan 15 04 there you go definitely and you know, honestly, the more success there is amongst all the designers just the more vibrant the galaxy store is just with, with lots of great content chris shomo 15 13 oh, yeah and just how it developed over time, too, because, like i've seen it, since the very beginning, when there was hardly anything on there and then just watching it explode to all these designs that you can't even imagine what's going to pop on there next it's exactly designed to blow me away all the time tony morelan 15 29 so chris is the person behind infinity watch faces, and truly is one of the first designers who started creating for the platform tell me what year was it that you actually started designing and selling on galaxy store? chris shomo 15 39 oh, goodness 2016 tony morelan 15 41 wow yeah so i actually did an episode on the podcast on chris last year, it was great episode, we talked about how you got your start creating for samsung and, and also that your house in savannah, georgia was featured in an episode of ghost hunters that it is haunted? chris shomo 15 56 yes, it is it's been quite an experience, even though i do believe that the ghost does appreciate me being here, i believe i do not know that but she's been pretty nice tony morelan 16 08 guys nice so if you want to learn much more about chris, go back to that episode and check it out it was it was a great show so in 2017, before i started working with samsung, you were actually invited to come out to san francisco and speak at the conference tell me about that chris shomo 16 22 wow, it was quite an experience and first off, it was my first developers conference, first type of any type of tech conference so i was a little nervous in the very beginning because here i am, i'm going to san francisco, and i'm getting ready to speak in front of a lot of other designers and developers what an experience it was great tony morelan 16 43 i'm sure it was nice to actually meet also the people, you know, not only at samsung, but then you know, some of the fellow developers that are part of this community chris shomo 16 51 yeah, and also met a lot of people that became future designers of for specifically watch faces, which was wonderful they always come back to me and be like, hey, i was there and i'm like, i remember you and you know, and they take off and they do very well yeah tony morelan 17 06 so i actually came across a video on youtube of you speaking at the conference and that's how i actually got my start how i first discovered that, you know, you can create these watch faces and, and start selling them for samsung now, i took it a step further and actually started working for samsung eventually chris shomo 17 23 yep and i think that's amazing i remember you sent me an email one time actually telling me that i had a typo on my website that's right and i was like, whoa, thank you, because it was just, uh, you know, no one wants a stupid typo on their website so i got that fixed and, and then i never knew that, you know, i'd be working with yeah, back and forth, like we are now and stuff so it's great it's amazing how everything is connected tony morelan 17 49 yeah so earlier this year, we announced a partnership with google and warehouse and introduced watch face studio to new tool for designing galaxy watch faces that are sold on the google play store when the tool was first developed, we asked you to be part of that early access team so can you tell me about that experience, how it is working with that tool, and what it's like to now publish on google play? chris shomo 18 10 well, first off, thank you for getting me in there and you recommended me for being part of that team and it was excellent to be part of it, because i was able to kind of push it to its limits for animations i had a really long animation, i was testing with it and i was sending it back and forth with samsung and it helped them iron out and smooth out how the animations were working on the watch and that was great and, you know, of course, there's going to be a little bit of growing pains in the very beginning we're working on that but it's been amazing how the team at samsung has been so responsive and to get the software right for us you can really create some masterpieces so i'm excited about this tony morelan 18 55 yeah, and that's why i thought it was so important to have you part of that team is because really your designs are not like the typical design i mean, you really do push the software to try and get the most out of it you know, they're there's fun, they're quirky, i mean animations are a huge part of your designs so is there anything new and exciting that we can anticipate coming out in the in the near future? chris shomo 19 15 oh, wow i don't really know myself because i kind of jumped around so much with these designs, which is another reason why yeah, i guess it's kind of unexpected and surprising when another one comes out at one time you'll have like dancing tigers in the next second you have dolphins and sea turtle swimming i'm working on getting one onto the google play store right now called flip out that has the dolphins and the sea turtles and then tiger time as well and then we got a giant eyeball for halloween that she's showing up so yeah, a bunch of different things tony morelan 19 48 you've got it in there they're super crazy they're very artistic chris shomo 19 51 thank you yeah, and it also one of the things that i like to concentrate on is trying to bring joy to people with the watch face is where they look at it and you know, just for a moment of time, they can actually, you know, take a break from reality, they get absorbed into the watch smile for a minute if that happens, and i know it's exceeded tony morelan 20 13 it also what i love is how you build in this sort of like goals where the watch will change, like, lets you step into an example, as you're reaching your different step goals throughout the day, your watch face then is also changing throughout the day chris shomo 20 27 and that started out of course, with the ties and watches and it worked with every one step goal percentage that they set with the watch and that was another thing that i'm glad i was in the beta because i was really expressing how much we needed a step goal percentage and to work with it, and they added it in after i requested it and it was really quick and of course there are some differences where we have to set the watch pace to its unique step goal as opposed to the user set step go but that's because of that they're trying to make it so it's compatible with all the different watches and where it was but that's cool, it opens up a new line of challenge faces where you can reach 1000 steps for this to happen 2000 steps for this to happen and i think it's really going to open the door for a lot of unique and creative designs tony morelan 21 17 you know, you brought up a great point that i always stress and that is how approachable samsung is to our developer community samsung really does listen to our developers and we actually want to have that one on one communications you know, through our different channels, it is really easy to reach out to us and we'll give you that that personal attention that we know our developers need when they're creating for samsung chris shomo 21 39 and i've really watched the developers program grow over time too because back in 2016 you know it was kind of a shot in the dark but everybody was like new to it samsung was new to this the watch faces and working with this well ready to be flooded of designers that are getting ready to come in and then every one of samsung embraced us we feel like we're part of a family tony morelan 22 02 thanks thanks, chris i got to thank you for jumping in and joining us on the podcast when sdc is back in person i hope to see you there, if not sooner, i will definitely be there chris shomo 22 10 count me in tony morelan 22 12 awesome thanks, chris thanks eric cloninger 22 15 it was great to hear from chris he's a part of the community of designers and developers that really make the galaxy store special tony morelan 22 22 yeah, he's been there from pretty much day one so it was great to catch up with chris and like i said, i can't wait to actually see him in person so it past sdcs, we've done what's called the best of galaxy store awards, i think, sec 18 was the first time that we did the show at the conference sec 19 that's when i actually hosted it down in san jose, it was great we have a lot of the winners actually, at the conference, we're able to recognize them for the great apps that they've created for galaxy store however, last year in 2020, because we did not have a conference, we did a virtual award show this was presented on youtube as a life premiere and it really actually was a lot of fun because we were able to reach out to a quite a big audience eric cloninger 23 09 one of the things i thought was cool about that once we all said in the chat room, it was in the early evening us time, but there were people logging in from russia and the czech republic and slovenia all of these developers and designers who had created things in one go is the middle of their night, but they were on there congratulating each other tony morelan 23 29 i think it really shows how the award show is really a global award show i mean we've got winners from all around the world winners from large companies down to indie designers and developers and it really is a huge, huge community eric cloninger 23 45 i think it shows how the galaxy store enables a lot of smaller operations, smaller individuals who may get lost in a larger organization that they can actually create something and monetize it and enjoy the success that they can have from their own work tony morelan 24 03 yeah, no that's very true that being said, though, there have been some pretty big names that we've recognized with awards in the past we've given awards to tik tok, epic games fortnite, microsoft with their franchise forza, top golf, that was another one and then there's a great company butterfly affected that his license big brands like spongebob, hello kitty, and star trek, it was great to see them recognized for their work eric cloninger 24 31 and also last year, for the first time, bixby developers had the opportunity to have their capsules judged and in 2020 the winner was spotify tony morelan 24 43 yeah, it was a lot of fun i actually worked on many of the trailers that were shown in the award show and spotify was one of the ones that i really, really enjoyed doing, not only the voiceover for but integrating the music and all the editing that was that was a lot of fun to work on that project and we look forward to that in 2021 eric cloninger 24 59 and so when is the award show this year tony morelan 25 05 so the award show will be part of sdc so that is on october 26 later on in the evening, though, we're going to be doing a premiere on youtube at 6pm eastern, and we will be participating in a live chat so we would love for, you know, not only the winners will be on participating in this live chat, but we would love just to have the community on there so we can all get together as a chance to, you know, congratulate the winners, and really talk about all of the great apps that were recognized during the award show eric cloninger 25 35 yeah, the one thing about this, that i think we did have a lot of fun with it last year, and we hope to have more fun this year in that chat session, the invitation goes out to really everyone who is interested in the galaxy ecosystem and that could be anybody who is a user or a consumer or a developer or a designer you know, we want to we want to celebrate everyone's hard work tony morelan 25 59 definitely, definitely and if you would like to actually go back and see who the previous winners are, and actually learn more about this upcoming award show, you can go over to developer samsung com forward slash awards to learn more about the best of galaxy store award show so let's talk about sdc 21 as you know, it's a virtual show that will be on october 26 where can people find out more information about registering to attend the virtual conference? eric cloninger 26 28 so the conference is free for anyone to attend, and you can learn more at developer samsung com slash sdc tony morelan 26 38 let's talk about some of the sessions what can you share about the sessions at sdc 21? eric cloninger 26 44 well, i don't want to steal any of the thunder from the product teams have been working so hard for the last year but it will tell you that most every technology team that is working on products at samsung will have something to talk about at sdc so if you're interested in the one ui beta, you'll learn a lot more about that at the sessions, the watchface tools, there's a podcasting platform that's brand new that i think you know something about, tony morelan 27 09 yeah, yeah, no, i am helping out the podcast platform team we're excited samsung has their new podcast platform, making it easy for users to listen to podcasts and we're really excited because in october, we're going to be expanding this platform to countries in europe so it's really a big deal you can check out my session and i kind of walk you through how it is that you submit your podcast to samsung so do you have any insight on what is going to be featured in the keynote, eric cloninger 27 38 i do have a little bit of information to share and one of the things that is always kind of fun with the keynote at sdc is that samsung president dj koh will be speaking as well as many other people from within the design and engineering teams at samsung as you know, the last physical sdc was in 2019, your seems like our world has kind of stopped but to be honest, the pace of technology keeps on moving and so nearly every samsung technology team will be there and they want to talk about all the innovation creation that they've done in the last two years so there'll be things announced for nearly every technology team from bixby and smartthings to mobile devices and smart tvs there's lots of information for developers that they will be able to use to create their own products for 2022 and beyond tony morelan 28 34 so really exciting sdc 21 is going to be october 26 eric cloninger 28 39 and if you want to attend, all you have to do is register at developer samsung com/sdc it's free to attend and we would love to see you there tony morelan 28 51 excellent hey, eric, thanks so much for being on the podcast super exciting to be back at it with sdc and i can't i can't wait for it eric cloninger 28 59 oh, absolutely it's really, it's the result of a year's worth of work by hundreds of people and we really want to share it with all the people out there tony morelan 29 10 yeah, it should be a great show right thanks, eric all right eric cloninger 29 13 thank you, tony closing 29 14 looking to start creating for samsung, download the latest tools to code your next app, or get software for designing apps without coding at all sell your apps to the world on the samsung galaxy store check out developer samsung com today and start your journey with samsung tony morelan 29 30 the pow! podcast is brought to you by the samsung developer program produced by tony morelan
tutorials galaxy watch
blogwatch face studio (wfs) is an intuitive graphical tool that provides designers a means to design watch faces for the wear os smartwatch ecosystem without the need for coding. basic information on a watch face is typically presented as text, and watch face studio enables you to customize how the text is displayed. this article introduces three features you can use to enhance the text on your watch face design: tag expressions curved text bitmap fonts you can follow along with the demonstrations in this blog by downloading the sample project. tag expressions tag expressions enable you to create watch face components for which the rotation, placement, and opacity changes based on tag values. the tag values represent watch data, such as the date and time, battery status, sensor and health data, moon phase, and mathematical operations. for example, you can create a watch face that shows the date and time, and a progress bar that fills up each minute. this section describes how to implement this using tag expressions. to implement the dynamic watch face: create a text component. in the "properties" panel, select the text field text box. select the tags button that appears. figure 1: tags button to add the hour text, from the tag list, select [hour_0_11], then select done. figure 2: tags list similarly, to add the minutes text, create a text component with the [min] tag. to implement the progress bar for the seconds display: a. create a progress bar component. b. define its value as the [sec] tag and set its maximum value to 60. create text components for the date-related elements: [day_week_f] (day of the week), [mon_f] (name of the month), and [day_1_31_z] (day of the month). noteyou can also display the weekday and month information as numbers, by using different tags. keep in mind that in watch face studio, sunday is the first day of the week. the following figure shows the progress bar on the watch face after some visual adjustments. figure 3: seconds progress bar on watch face for more examples of tag expression implementation, see the tag expressions code lab for watch face studio. curved text you can place text around a curve by selecting from predefined angular ranges, or by defining a specific start position and distance. you can also easily set the text direction. to place curved text around the top of the watch face: create a text component and define the text you want to display. in the "properties" panel, select apply curved-text. select ok. the curved text settings appear. in the "curving" fields, define the width and height of the circle or oval around which the text is to be placed. the width and height values are in pixels. for this demonstration, set both the width and height to 436. to place the text around the top of the watch face, in the "range" section, select the upper half circle. figure 4: configuring the curved text the following figure shows the curved text on the watch face after some visual adjustments. figure 5: curved text on a watch face noteyou can also implement curved text on complications. bitmap font bitmap fonts enable you to replace information on the watch face, such as digits, symbols, and day of the week, with customized images. use different icons and images in the bitmap font to make your watch face more interesting. to implement icons for the am/pm tag: create a text component. in the "properties" panel, select the text field text box. select [ampm] from the tags list, and select done. figure 6: am/pm tag in the "text appearance" section, select bitmap font. open the "bitmap font setting" dialog. figure 7: bitmap font configuration in the "bitmap font setting" dialog, select the other tab. to add an image for a specific string, select + and browse to the image on your computer. do this for both the "am" and "pm" strings. to close the dialog, select ok. figure 8: adding a bitmap font image the watch face displays the selected images in place of the "am" and "pm" text strings. a watch face can have multiple bitmap fonts. you can add another bitmap font from the dropdown menu and apply different bitmap fonts to different text elements. figure 9: creating another bitmap font notethe sample project contains two bitmap fonts. conclusion watch face studio provides various text options for the watch face. the text customization features described in this blog can help you create an eye-catching watch face. resources for more information about watch face studio, see the watch face studio documentation. you can also visit the samsung developers forums, an active and friendly community where you can ask for and receive help with your application development. the samsung developers site has many resources for developers looking to build for and integrate with samsung devices and services. stay in touch with the latest news by creating a free account and subscribing to our monthly newsletter. visit the marketing resources page for information on promoting and distributing your android apps. to learn more about customizing your watch face, see also the design complications using watch face studio blog.
Most Fowziya Akther Houya
Learn Code Lab
codelabbuild a health app with steps from samsung health and its connected wearables objective create a step counter application for android devices, utilizing the samsung health data sdk to read steps data collected by the samsung health app overview samsung health offers various features to monitor user health data such as their daily step activity with the samsung health data sdk, android applications can easily access collected data, including steps recorded over a specific period or from a certain device you can retrieve steps data collected by samsung health, obtain the total number of steps taken within the day, and the total number of steps per hour, and apply local time filters to refine your queries effectively set up your environment you will need the following android studio latest version recommended java se development kit jdk 17 or later android mobile device compatible with the latest samsung health version sample code here is a sample code for you to start coding in this code lab download it and start your learning experience! health data steps sample code 573 9 kb set up your android device click on the following links to set up your android device enable developer options run apps on a hardware device activate samsung health's developer mode to enable the developer mode in the samsung health app, follow these steps go to settings > about samsung health then, tap the version number quickly 10 times or more if you are successful, the developer mode new button is shown tap developer mode new and choose on now, you can test your app with samsung health notethe samsung health developer mode is only intended for testing or debugging your application it is not for application users start your project in android studio click open to open existing project locate the downloaded android project mysteps from the directory and click ok check gradle settings before using the samsung health data sdk library, certain configurations are necessary these steps are already applied in the sample code provided the samsung-health-data-api-1 0 0b1 aar library is added to the app\libs folder, and included as a dependency in the module-level build gradle file in the same file, the gson library is also added as a dependency dependencies { implementation filetree mapof "dir" to "libs", "include" to listof "* aar" implementation libs gson } next, the kotlin-parcelize plugin is applied plugins { id "kotlin-parcelize" } lastly, the following entries are also added in the gradle > libs version toml file [versions] gson = "2 10 1" parcelize = “1 9 0” [libraries] gson = { module = "com google code gson gson", version ref = "gson" } [plugins] parcelize = { id = “org jetbrains kotlin plugin parcelize”, version ref = ”parcelize” } request steps data permissions noteyou can access data from samsung health by obtaining a healthdatastore object using the healthdataservice getstore appcontext method to read data from samsung health, you need to acquire proper permissions from the app user each health data type has its own permission additionally, separate permissions are required for reading and writing operations the user must grant the following permissions in the app steps for read operation steps_goal for read operation when launching the application, it is important to verify if the necessary permissions have already been granted this can be achieved through the library function healthdatastore getgrantedpermissions permissions set<permission> set<permission> go to app > kotlin+java > com samsung health mysteps domain in the arepermissionsgrantedusecase kt file, navigate to the permissions object and create the permissions needed to read the steps and steps goal data from samsung health /**************************************************************************** * [practice 1] create permission set to receive step data * * make permissions set down below contain two permission * com samsung android sdk health data permission permission objects of types * - 'datatypes steps' of 'accesstype read' * - 'datatypes steps_goal of 'accesstype read' ****************************************************************************/ object permissions { //todo 1 val permissions = emptyset<permission> } if the permissions are not granted, invoke an ask-for-permissions view the special function provided by the library is called from mainactivity, where the context is an activity's context val result = healthdatastore requestpermissions permissions, context after invoking the function, the app user sees the following pop-up upon starting the application if the user does not consent to read their steps data, the application displays a message explaining why this authorization is vital for the app to function properly notepermissions can be granted or revoked at any time by tapping the more button on the toolbar and selecting the connect to samsung health tab once the user grants the necessary permissions, you can proceed with retrieving the step data from the healthdatastore retrieve steps data from samsung health understand how to retrieve step goal a step goal is a target number of steps set by an individual to achieve within a day this can be set in the samsung health app by navigating to steps > settings > set target check the readlaststepgoal function in readstepgoalfromtodayusecase kt to know how to retrieve the most recent step goal from samsung health @throws healthdataexception class private suspend fun readlaststepgoal int { val startdate = localdate now val enddate = localdate now plusdays 1 log i tag, "startdate $startdate; enddate $enddate" val readrequest = datatype stepsgoaltype last requestbuilder setlocaldatefilter localdatefilter of startdate, enddate build val result = healthdatastore aggregatedata readrequest var stepgoal = 0 result datalist foreach { data -> log i tag, "step goal ${data value}" log i tag, "data starttime ${data starttime}" log i tag, "data endtime ${data endtime}" data value? let { stepgoal = it } } return stepgoal } the function readlaststepgoal retrieves the most recent step goal from samsung health first, it filters the data by setting the startdate and enddate to the current date and the next day respectively using a localdatefilter next, the function builds a request using the datatype stepsgoaltype last constant to retrieve the most recent value and specifies the date range using the setlocaldatefilter method the request is then executed by calling the aggregatedata function of the healthdatastore once the data is fetched, the function loops through each entry and extracts the step goal value finally, it returns the step goal value as the result collect today's total number of steps to verify if the user reached their daily step goal, get the number of steps taken from midnight until the current time perform this calculation by creating a generic function that calculates the total number of steps within a specified time frame then, set the start time as the beginning of today and the end time as the current timestamp total is an aggregate operation that obtains the sum of steps to achieve this task, use the following healthdatastore getgrantedpermissions permissions set<permission> set containsall elements collection<@unsafevariance e> aggregaterequest it represents a request for an aggregation query over time it is used to run aggregate operations like total and last for healthdatapoint localtimefilter filter with a localdatetime type time interval as a condition the time interval is represented as local date time companion function of starttime localdatetime?, endtime localdatetime? creates a localtimefilter with starttime and endtime aggregaterequest localtimebuilder<t> provides a convenient and safe way to set the fields and create an aggregaterequest setlocaltimefilter localtimefilter localtimefilter sets the local time filter of the request in readstepsfromatimerangeusecase kt, navigate to the function getaggregaterequestbuilder and filter today's steps /*************************************************************************** * [practice 2] - create a read request builder to obtain steps from given * time range * collecting steps from a period of time is an aggregate operation which * sums up all the steps from that period * in this exercise you need to * - create a localtimefilter with starttime and endtime for the * aggregaterequest * - apply the filter to the aggregaterequest * ------------------------------------------------------------------------- * - hint * use localtimefilter of to create a time filter for the request **************************************************************************/ fun getaggregaterequestbuilder starttime localdatetime, endtime localdatetime aggregaterequest<long> { val aggregaterequest = datatype stepstype total requestbuilder build // todo 2 return aggregaterequest } a list of aggregated data is received as a result of the request in this example, it's a single-item list containing the total number of steps taken from the beginning of the day to the present moment with the given code, you can iterate over the list and check if the value of the analyzed aggregateddata element is not null if so, assign it to the stepcount variable however, if the value is empty, the code returns a value of 0, indicating that no steps were recorded val result = healthdatastore aggregatedata aggregaterequest var stepcount = 0l result datalist foreach { aggregateddata -> aggregateddata value? let { stepcount = it } } obtain the number of steps for each hour after setting up the functions to fetch steps data from samsung health and aggregating the data to calculate the total step count, you need to obtain the total number of steps for each hour and visualize the steps the user took during every hour of the day to achieve this, utilize the aggregate operation sum of steps , but this time incorporate additional filtering grouping by hour aggregaterequest it represents a request for an aggregation query over time it is used to run aggregate operations like total and last on healthdatapoint localtimefilter filter with a localdatetime type time interval as a condition the time interval is represented as local date time companion function of starttime localdatetime?, endtime localdatetime? creates a localtimefilter with starttime and endtime localtimegroup grouped time interval with a pair of localtimegroupunit and multiplier this means that the grouping is applied to intervals as much as multiplier in local date and time companion function of timegroupunit localtimegroupunit, multiplier int creates a localtimegroup with the given timegroupunit and multiplier localtimebuilder<t> provides a convenient and safe way to set the fields and create an aggregaterequest setlocaltimefilterwithgroup localtimefilter localtimefilter?, localtimegroup localtimegroup? sets the local time filter with the local time group of the request in readgroupedstepsbytimerangeusecase kt, navigate to the getaggregaterequestbuilder function obtain the total number of steps from every hour by creating two variables one to specify the time range using localtimefilter of and another to define the grouping using localtimegroup of by combining these variables, you can set an aggregate request that retrieves the desired data /************************************************************************ * [practice 3] - create an aggregate request for steps from given period * of time * for this, datatype steps grouped by hour is needed * in this exercise you need to * - create an aggregate request, with grouping and time filters, * for filters' parameters use the method's arguments * - return the request * ---------------------------------------------------------------------- * - hint * use setlocaltimefilterwithgroup function to apply time and grouping * filters to the request builder ***********************************************************************/ fun getaggregaterequestbuilder startdatetime localdatetime, enddatetime localdatetime, localtimegroupunit localtimegroupunit, multiplier int aggregaterequest<long> { val aggregaterequest = datatype stepstype total requestbuilder build // todo 3 return aggregaterequest } to apply local time filtering with the given group, use the localtimefilter and localtimegroup classes the localtimegroup consists of a localtimegroupunit, which in this case is hourly, and a multiplier you can also group by other time periods such as daily, weekly, monthly, minutely, and yearly since you want data from every hour period, use a multiplier value of 1 the returned data from the request is a list, where each item represents a grouped value healthdatastore only returns values for periods when the step count is greater than zero the code below shows that by iterating over the returned datalist and adding non-null groupeddata to the output steplist, you can obtain the aggregated value of steps for each hour of the day val result = healthdatastore aggregatedata aggregaterequest val steplist arraylist<groupeddata> = arraylist result datalist foreach { aggregateddata -> var stepcount = 0l aggregateddata value? let { stepcount = it } val starttime = aggregateddata starttime atzone zoneid systemdefault val groupeddata = groupeddata stepcount, starttime tolocaldatetime steplist add groupeddata } noteevery usage of samsung health data sdk might throw a healthdataexception such exceptions are thrown from every backend function up the call stack and handled in viewmodel the healthdataexception has four possible subclasses an example is resolvableplatformexception, which means it can be automatically resolved by invoking resolvableplatformexception resolve activitycontext the reason for such an exception is, for instance, when samsung health app is not installed on the device resolving it results in opening samsung health page in the app store run unit tests for your convenience, an additional unit tests package is provided this package lets you verify your code changes even without using a physical device right-click on com samsung health mysteps test and select run 'tests in 'com samsung health mysteps' 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 app on a connected device to read your steps data once the app starts, allow all permissions to read steps data from samsung health and tap done afterwards, the app's main screen appears, displaying the daily summary of steps taken, target, and steps by hour swipe down to sync the latest data from samsung health you can scroll down to steps by hour to see the hourly breakdown you're done! congratulations! you have successfully achieved the goal of this code lab now, you can create a mobile health app that reads samsung health steps count data by yourself! if you are having trouble, you may download this file health data steps complete code 573 4 kb to learn more about samsung health, visit developer samsung com/health
tutorials iot
blogmatter is an open-source connectivity standard for smart home and internet of things (iot) devices. it is a secure, reliable, and seamless cross-platform protocol for connecting compatible devices and systems with one another. smartthings provides the matter virtual device application and smartthings home apis to help you quickly develop matter devices and use the smartthings ecosystem without needing to build your own iot ecosystem. supporting iot devices that can be operated from outside the home requires significant infrastructure investment. a cloud server must be built and maintained to deliver commands to the home, and if the device uses a mesh network technology such as thread, the user needs to have a supported hub in the home. users are also typically uninterested in purchasing multiple hubs to support all the brands of iot devices that they own. the smartthings home api, announced at sdc 2023, allows you to leverage the smartthings infrastructure for your own matter and iot products. the api enables you to use the smartthings cloud, which means your application can support matter devices connected to any of the 1.7 million smartthings hubs worldwide. in this tutorial, you will learn how to use the smartthings home apis to develop an iot application that onboards, controls, shares, and removes a smart lock device. for more information about smartthings matter, see matter in smartthings. prerequisites to follow along with this tutorial, you need the following hardware and software: host pc running on windows 10 (or higher) or ubuntu 20.04 (x64) android studio (latest version recommended) java se development kit (jdk) 11 or later mobile devices & smartthings station connected on the same network: mobile device with matter virtual device application installed mobile device with developer mode and usb debugging enabled matter-enabled smartthings station onboarded with the samsung account used for smartthings notethe smartthings home api materials, including the sample application project for this tutorial, are distributed only to authorized users. if you want permission to use the apis, contact st.matter@samsung.com. commission the device to onboard a matter-compatible device to your iot application, you must commission the device, joining it to the smartthings fabric. download the sample application project and open it in android studio. the following steps are implemented in the mainviewmodel.kt file at the path app > java > com.samsung.android.matter.home.sample > feature > main. step 1. create an instance of the matter commissioning client. step 2. call the commissiondevice() function to launch the onboarding activity in home service. step 3. set the value of _intentsender.value to the returned value. // todo 1 val commissioningclient = matter.getcommissioningclient() val intentsender = commissioningclient.commissiondevice(context) _intentsender.value = intentsender notefor all code examples in this tutorial, look for "todo #' in the sample application to find the location where you need to add the code. control the device capabilities are the core of the smartthings architecture. they abstract devices into their underlying functionalities, which allows you to retrieve the state of a specific device component or control specific functionality. each device has its own set of appropriate capabilities, each controlled with its own api function. consequently, the more capabilities the device supports, the more application code is needed to implement it. the following steps demonstrate implementing the capabilities for a smart lock device. they are implemented in the smartlockviewmodel.kt file at the path app > java > com.samsung.android.matter.home.sample > feature > device. step 1. to retrieve lock, tamper and battery status of a device capability: a. retrieve the appropriate capability from the device instance. b. extract the stream value for the appropriate feature from the capability. c. store the retrieved value for updating the ui. // todo 2 device.readcapability(lock)?.lock?.collect { lockunlock -> _lockstatus.value = lockunlock } // todo 3 device.readcapability(tamperalert)?.tamper?.collect { tamperalert -> _tamperstatus.value = tamperalert } // todo 4 device.readcapability(battery)?.battery?.collect { battery -> _batterystatus.value = battery } step 2. to control the lock status: a. retrieve the lock capability from the device instance. b. if lockstatus is unlock, call lock() function to close it. c. if lockstatus is not unlock, call unlock() function to open it. // todo 5 device.readcapability(lock)?.let { lock -> when (_lockstatus.value) { lockstatus.unlocked.statusname -> lock.lock() else -> lock.unlock() } } share the device using the smartthings home api, you can share matter devices connected to smartthings with other matter-compatible iot platforms without resetting the device. this enables the user to control the same device through additional controller applications, such as google home. the following steps are implemented in the baseviewmodel.kt file at the path app > java > com.samsung.android.matter.home.sample > feature > device > base. step 1. create an instance of the matter commissioning client. step 2. to launch the sharedevice activity in home service, call the sharedevice() function. step 3. set the value of _intentsenderforsharedevice.value to the returned value. // todo 6 val commissioningclient = matter.getcommissioningclient() val intentsender = commissioningclient.sharedevice( context, commissioningclient.sharedevicerequest(deviceid) ) _intentsenderforsharedevice.value = intentsender remove the device you can remove the device from the iot application and the smartthings fabric. the following steps are implemented in the baseviewmodel.kt file at the path app > java > com.samsung.android.matter.home.sample > feature > device > base. step 1. create an instance of the matter commissioning client. step 2. to launch the removedevice activity in home service, call the removedevice() function. step 3. set the value of _intentsenderforremovedevice.value to the returned value. // todo 7 val commissioningclient = matter.getcommissioningclient() val intentsender = commissioningclient.removedevice( context, commissioningclient.removedevicerequest(deviceid) ) _intentsenderforremovedevice.value = intentsender test the application to test the sample iot application with a virtual smart lock device: step 1. build and run the project on your android device. when you launch the application, it is synced to the smartthings application and your connected matter devices and hubs are listed on the home screen. step 2. to create a virtual smart lock device: a. launch the matter virtual device application on your other mobile device. b. select “door lock,” then tap “save” and “start” to receive a qr code. step 3. within the sample iot application, to onboard the virtual smart lock, tap “+” and scan the qr code. step 4. to lock and unlock the virtual smart lock, tap the button in the iot application. conclusion this tutorial has demonstrated how you can create an application to onboard and control a smart lock using the smartthings home api. to learn about onboarding and controlling other device types, go to code lab (matter: build a matter iot app with smartthings home api). for more information about smartthings matter, see matter in smartthings.
HyoJung Lee
tutorials mobile
blogsamsung wallet enables users to easily access various digital content, such as boarding passes, tickets, and coupons, on their samsung device. users can save the content to their samsung wallet by clicking an “add to wallet” button or link. this article describes how to integrate your digital content with samsung wallet. each piece of digital content is represented by a wallet card which you must create and launch within the samsung wallet portal. after successfully launching the card, you can create an “add to wallet” link for it. prerequisites before you can create wallet cards for samsung wallet, complete the samsung wallet partner registration and onboarding process, including encryption setup. after onboarding, you receive an email with your public key and signed security certificate. keep this information in a safe place. important your company can only obtain partnership for a single samsung account. store your private key securely, as it is needed for wallet card management. your encryption settings cannot be modified without administrator approval. creating wallet cards samsung wallet supports the following wallet card types: boarding pass event ticket coupon gift card loyalty card id card create your wallet card at the samsung wallet portal. you can create as many cards as you need. the samsung wallet portal also allows you to manage your cards and monitor their performance. testing wallet cards use the “add to wallet” test tool to test the card at any time, before or after launching it: in the samsung wallet portal, enable testing mode for the card you want to test. skip this step if you have already launched the card. on your samsung device, go to the “add to wallet” test tool and sign in with your samsung account. select the card from the list and provide test data in the appropriate fields. in the “partner’s private key” field, paste your decrypted private key. this must be the same private key that was used during onboarding. noteif your private key is encrypted, you must first decode it with the ssl command. an encrypted key starts with the following text: -----begin encrypted private key----- once decoded, the key starts with the following text: -----begin private key----- 5. tap the “add to samsung wallet” button to add the card to samsung wallet on your device. for more information about testing wallet cards, see “add to wallet” test tool. launching wallet cards when you are ready to make the wallet card accessible to users, click “launch” to start the verification process. launching a card cannot be canceled. figure 1: wallet card launched the samsung wallet administrator reviews the card and approves or rejects it. if your card is rejected, check the rejection email for the reason. modify the card to address the issue and launch it again. for more information about wallet card verification, see launch wallet cards (verifying status) and launch wallet cards (rejected status). implementing “add to wallet” links after launching your wallet card, create a link that users can click to add the content to their samsung wallet. to include the card data in tokenized form, use the following url format: https://a.swallet.link/atw/v1/{card id}#clip?cdata={cdata token} where: {card id} path parameter is the unique identifier for the wallet card in the samsung wallet portal. #clip hash parameter is case-sensitive. cdata query parameter contains the encrypted card data in jwt format. for more information, see the "cdata token generation" section below. if the encrypted card data is longer than 2048 bytes, or you do not want to include the tokenized data in the url, store and reference the card data on your server. create the url in the following format: https://a.swallet.link/atw/v1/{card id}#clip?pdata={reference id} where: {card id} path parameter is the unique identifier for the wallet card in the samsung wallet portal. #clip hash parameter is case-sensitive. pdata query parameter is the unique identifier for the card data stored on your server. for more information on “add to wallet” links, see add to wallet interface. cdata token generation the card data in basic json format must be provided as a jwt (json web token). for token generation details, see security. you can also study the cdata generation sample code. to ensure your cdata token is valid, keep the following requirements in mind: pay attention to the mandatory fields in the card object. all timestamps are utc epoch time in milliseconds. card data attributes vary based on the card type. for detailed card data specifications, see wallet cards. your private key must match the key used for the security certificate signed by samsung. if you are using the correct private key, the following commands generate the same hash: $ openssl rsa -noout -modulus -in partner.key | openssl md5 $ openssl x509 -noout -modulus -in partner.crt | openssl md5 generated jwt tokens expire in 30 seconds. the “add to wallet” link must be used within this time. otherwise, you must generate a new token and new link. next steps to integrate the “add to wallet” feature as a button in your application or website, see implement the button. you can update the information on a card that has been stored in a user’s samsung wallet by communicating between your server and the samsung server. for information, see server interaction. if you have any questions or face difficulties implementing the content in this article, you can contact samsung developer support. related resources samsung wallet documentation integrate “add to samsung wallet” button into partner services code lab
M. A. Hasan Molla
events ai, iot, uiux, game, web, mobile, galaxy watch
blogthe samsung developer conference (sdc) for 2021 kicked off on october 26, 2021, and we hope you enjoyed the keynote and highlight sessions. as with many events, there is so much information to digest. fortunately, with the virtual format this year, developers can go back and review the sessions they've watched and study how they might take advantage of all the opportunities available with samsung platforms, sdks, and services. while there are too many announcements and technologies to cover in one post, here are some moments from the conference that should be interesting to developers. keynote samsung electronics president dj koh began the conference, as he's done in previous years. the keynote session included overviews of announcements that were described in more detail during the highlight sessions, tech talks, and code labs. voice control of iot devices (bixby/smartthings) samsung mobile senior vice president daniel ahn kicked off the announcements at sdc with a keynote session highlighting the integration of bixby voice control to the smartthings ecosystem with details from smartthings vice president samantha fein. technical talks with more details of the integration for developers and device manufacturers are also available. bixby : best voice interface for connected experience enabling intelligent voice control on your iot devices further, the smartthings platform team provided technical talks on the new smartthings edge platform and smartthings build for use in multi-family home environments. support for the matter standard was announced during the highlight session. samsung electronics vice president jaeyong jung and smartthings vice president samantha fein talked about the bright future for home automation with matter in this highlight session. the samsung newsroom has more information on the bixby and smartthings integration as well as the matter standard support. security and privacy with samsung knox samsung executive vice president kc choi details how samsung knox unlocks the $80b enterprise market with devices and services to ensure that critical data is secure and employee information is kept confidential. in the tech talk sessions below, samsung b2b product experts give developers the information they need to integrate their own apps and services for this lucrative market segment. samsung ese: a trusted partner for enhanced security redefining edge computing & foldables for b2b beyond a limit with the mobile b2b partner program developers with solutions for the enterprise market should sign up for the knox partner program. services and solutions for smarttv platform at sdc21, developers interested in smart tv solutions had plenty to learn. in the keynote, samsung eelectronics senior vice president yongjae kim and samsung research vice president bill mandel discussed many new and exciting opportunities for developers with the tizen platform, which are available for viewers to watch in these sessions. what's new in samsung smart tv services what’s new in tizen 6.5 what's next for tizen: smart screen for business build a trusted service with samsung tizen security what's new in the tizen web platform for smart tv game developers are rising stars with samsung the experience of the last 18 months has shown that self-care is important to our well-being. by allowing us to disconnect from reality, games help reduce stress and give a temporary reprieve from the stresses of daily life. samsung support for gamers and game developers comes to the forefront at sdc21 with these important sessions. galaxy store: games-focused, developer-friendly games for everyone: samsung instant plays in addition to mobile gaming, the announcement of hdr10+ for gaming will delight gamers looking forward to top-quality experiences on smart tvs. building better web experiences with samsung internet the samsung internet browser ships with every samsung galaxy phone. the developers and advocates for samsung internet want to ensure that consumers have the best possible experiences, mixing web content with mobile hardware. how to build browser extensions on samsung internet unfolding the future of responsive web design one ui brings beautiful and secure interactions to your mobile world samsung electronics executive vice president janghyun yoon unveiled the one ui 4 platform, showing numerous examples of beautifully designed cross-device experiences, such as taking a photograph from galaxy z flip3, sharing to the galaxy book, and editing using a galaxy tab s with s pen. while beauty is only skin deep, one ui 4 adds layers of security to these experiences. learn more about one ui 4 in these sessions. one ui 4 design: focus, comfort, self-expression one ui: designing a more approachable experience designers and developers explore new worlds with one ui watch platform galaxy watch4 was introduced at galaxy unpacked in august 2021. the one ui watch platform uses wear os powered by samsung. developers interested in bringing their ideas to the new platform should check out these talks. watch ecosystem: a new era build your app in the new watch ecosystem galaxy watch4 for enterprise business new health platform based on wear os powered by samsung further, designers who are interested in expressing their creative side with watch face designs should view this session on how to use watch face studio to create beautiful designs without writing code. rewarding successful developers with the best of galaxy store awards samsung sr. developer evangelist tony morelan presents the best of galaxy store awards, now in their 4th year. these awards are samsung's way to express gratitude to those developers and designers who are bringing beautiful and exciting apps, games, and themes to galaxy store. for the second year, the bixby team recognized the top developer and capsule for their platform. following up with samsung this site has many resources for developers looking to build for and integrate with samsung devices and services. stay in touch with the latest news by creating a free account and subscribing to our monthly newsletter. visit the marketing resources page for information on promoting and distributing your apps through the galaxy store. finally, our developer forum is an excellent way to stay up-to-date on all things related to the galaxy ecosystem. thank you for joining us for sdc21 and we look forward to seeing you in 2022.
Samsung Developers
tutorials web, mobile
blogfoldable devices are here! these smartphones allow different form factors with just one device, which can lead to new opportunities for innovation. as developers should be able to detect what is the current posture of the device, the physical position in which a device holds, samsung is putting an effort within the w3c on making a new web standard called device posture api. this api allows web applications to request and be notified of changes in the device posture. web apps can take advantage of the new form factors and improve users’ experience. we’ve created this codelab to show you how you can take advantage of this new feature. before we start, if you would like to learn more about it in a different format, here is a video that we’ve created with more information about this api and foldables. 👉 would you like to do this codelab with mentors and in person? if you are in london we will have a first meetup to try this with real foldable devices, feel free to register here! (ed. this event has already occurred, but we're leaving the link intact.) what is the w3c and why you should care in the meantime, as i’ve mentioned before, there is a current proposal about how to take advantage of these foldable devices called ‘device posture api’. its current state is ‘draft’, which means that is still open to changes and discussion and has been published for review by the community, including w3c members, the public (you!), and other technical organizations. we’ve created a demo to show you how to use this api, hear your thoughts and teach you some capabilities of the web. at the end of this codelab you can send us your feedback here. let’s start working… 🛠️ hands on 1. set up your environment you will need the following: samsung internet latest version samsung galaxy z fold2, z fold3, z flip, or z flip3 if a physical device is not available for testing, use a) remote test lab requirements: samsung account java runtime environment (jre) 7 or later with java web start b) device posture api polyfill for testing using a non-foldable smartphone, just implement a polyfill to the project. 2. start your project open a new browser tab, go to https://glitch.com, and log in click new project, then select import from github enter the url of this repository 3. add html video markup note: take a look and check the files of your project before starting to code. in index.html, you will have two main sections, one is dedicated to the video camera and the other one to the camera controls. you can identify the video section as it contains the class video-container. complete the html markup by adding the <video> element, width, height, and id attributes. <div class="video-container"> <video id="video" width="1280" height="200" > video stream not available. </video> </div> once the video markup is added, the html file is complete. besides this, you can find: a <canvas> element into which the captured frames are stored and kept hidden since users don’t need to see it. an <img> element where the pictures will be displayed. 4. enable front and back cameras with facingmode in index.js, you'll find a startup() function, here is where you will be doing the following: initialize most values grab element references to use later set up the camera and image start by setting up the camera. you will have access to both front and back cameras by using facingmode, a domstring that indicates which camera is being used to capture images. it's always a good practice to check if this function is available for use. add the following lines of code in startup(): `let supports = navigator.mediadevices.getsupportedconstraints(); if (supports["facingmode"] === true) { flip_button.disabled = false; }` 5. link the media stream to the video element if you are able to use facingmode, the camera web app will use this option in the capture function to detect which is the current camera used and later send it to the flip button. now, the camera should be activated, insert this block of code after retrieving defaultopts.video value using facingmode: `navigator.mediadevices .getusermedia(defaultsopts) .then(_stream => { stream = _stream; video.srcobject = stream; video.play(); }) .catch(error => console.error(error));` in order to get the media stream, you call navigator.mediadevices.getusermedia() and request a video stream that returns a promise. the success callback receives a stream object as input. it is the <video> element's source to the new stream. once the stream is linked to the <video> element, start it playing by calling video.play(). it's always a good practice to include the error callback too, just in case the camera is not available or the permissions are denied. 6. take a look at the implementations in index.js at this point, the functionality of the web app is complete. before moving to the next step, let’s review the rest of the javascript code: there is an event listener video for the canplay event that will check when the video playback begins. if it's the first time running, it will set up video attributes like width and height. for the snip button, there is an event listener for click that will capture the picture. the flip button will be waiting for a click event to assign the flag about which camera is being used, front or back camera, within the variable shouldfaceuser, and initialize the camera again. clearpicture() creates an image and converts it to a format that will be displayed in the <img> element. finally, takepicture() captures the currently displayed video frame, converts it into a png file, and displays it in the captured frame box. 7. use the device posture api at this point, you should have a working prototype of a camera web app. the video camera should be displayed and a picture may be taken using the snip button. in addition, it will show a preview of the picture taken through the small preview display. the flip button allows you also to switch between front and back cameras. now, it’s time to play around with the layout of the web app and take advantage of the features available on a foldable device. in order to do that, you will implement the device posture api that allows developers to detect what is the current posture of the phone. in order to change the layout when the device is partially folded, the device posture that you will look for is in a form of a book or laptop. in style.css, apply the following media query: @media (device-posture: folded) { body { display: flex; flex-flow: column nowrap; } .video-container .camera-controls { flex: 1 1 env(fold-bottom); } .msg { display:block; margin: 5em; } using modern css features like display:flex and grid, you can change the layout of the body element and the elements with the class video-container and camera-controls when the phone is flipped. 8. test your app whether you test on a real foldable phone or on a remote test lab device, you need to enable the device posture api in the latest version of samsung internet. to do this, open the browser and type internet://flags in the url bar and search for either device posture api or screen fold api, then select enable. test in a real device if you have a real physical device, you can test it directly on samsung internet using the url that glitch provides you by clicking on show in a new window menu. just partially fold your phone and you will see how the layout changes and even discover a hidden message! use remote test lab the other option, if you don’t have a physical device, is by using remote test lab. you can choose any galaxy foldable devices from the list and follow the same instructions as you would with a real device. just make sure to enable the device posture api and have the latest version of samsung internet. use the buttons provided by remote test lab to partially fold your remote galaxy device. implement polyfill polyfill allows you to emulate behavior on devices that do not have folding capabilities. it helps you visualize how the content responds to the different angle and posture configurations. just include sfold-polyfill.js directly into your code and use the polyfill settings (screenfold-settings.js) of the web component that will emulate the angle of the device and therefore, it will change its posture. moreover, add the following code in index.html <head> … <script type='module' defer src="screenfold-settings.js"></script> <script src="sfold-polyfill.js"></script> … </head> <body> <section> <screenfold-settings></screenfold-settings> </section> … </body> 🥳 you did it! you’ve created a web app that detects when a foldable device change its posture. please let us know how it went here, we would like to hear your thoughts around this api, future codelabs and more! this feedback will go directly to the w3c devices and sensors group, so you will be part of the conversation around this draft too! thanks a lot for reading.
Laura Morinigo
Learn Code Lab
codelabmatter create a virtual device and make an open source contribution objective learn how to create a matter virtual device, which you can control using the smartthings app also, know how to contribute your code to matter open source overview matter is an open-source connectivity standard for smart home and internet of things iot devices it is a secure, reliable, and seamless cross-platform protocol for connecting compatible devices and systems with one another smartthings provides the matter virtual device app and smartthings home apis to help you quickly develop matter devices and use the smartthings ecosystem without needing to build your own iot ecosystem you can use smartthings home apis to onboard, control, remove, and share all matter devices when building your application other iot ecosystems can use the matter devices onboarded on your iot app through the multi-admin function notethis code lab focuses only on creating a matter virtual device you can control using the smartthings app to learn how to make your controller app, see build a matter iot app with smartthings home apis for detailed information, go to partners smartthings com/matter set up your environment you will need the following host pc running on windows 10 or higher or ubuntu 20 04 x64 android studio latest version recommended java se development kit jdk 11 or later devices connected on the same network mobile device with android 8 0 oreo or higher operating system os mobile device with smartthings app installed matter-enabled smartthings station onboarded with samsung account used for smartthings app initial setup turn on developer mode and enable usb debugging option on your mobile device install a few os-specific dependencies by entering the below command in your terminal window $ sudo apt-get install git gcc g++ pkg-config libssl-dev libdbus-1-dev \ libglib2 0-dev libavahi-client-dev ninja-build python3-venv python3-dev \ python3-pip unzip libgirepository1 0-dev libcairo2-dev libreadline-dev to build the matter virtual device app, install sdk platform 26 and ndk version 22 1 7171670 using sdk manager in android studio after installing ndk, register the ndk path to the env path export android_ndk_home=[ndk path] export path=$path ${android_ndk_home} install kotlin compiler kotlinc version 1 5 10 after installing kotlinc, register the kotlinc path to the env path export kotlinc_home=[kotlinc path]/bin export path=$path ${kotlinc_home} sample code here is a sample code for you to start coding in this codelab download it and start your learning experience! matter virtual device sample code 11 42 mb 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 from the directory and click ok select and create the device type when you build and run the sample matter virtual device app, you can see the already added on/off switch aside from the switch, other types of devices you can create are already prepared in the sample app noterefer to the matter device library specification for the list of matter devices you can create go to feature > main > java > com matter virtual device app feature main in the mainfragment kt file, select the device type you want to create mainuistate start -> { // =================================================================================== // codelab // todo uncomment the following lines to add your own device type // ----------------------------------------------------------------------------------- val itemlist = listof device onoffswitch, // sample // device occupancysensor, // level 1 8+ mins // device contactsensor, // level 2 8+ mins // device videoplayer, // level 2 10+ mins // device doorlock, // level 3 15+ mins // device extendedcolorlight, // level 3 15+ mins // device windowcovering, // level 4 17+ mins // device thermostat, // level 5 20+ mins // =================================================================================== depending on the device type you selected at this step, the part you need to modify at the next step will vary the level of modification complexity is assigned per each device get cluster value clusters are the functional building block elements of the data model a cluster can be an interface, a service, or an object class, and it is the lowest independent functional element in the data model a matter device supports a set of appropriate clusters, which can interact with your preferred controller such as smartthings this allows for easy information retrieval, behavior setting, event notifications, and more through the viewmodel, get the value of the cluster used in the device you created noteto learn more about clusters, see matter application cluster specification occupancy sensorlevel 1 file path feature > sensor > java > com matter virtual device app feature sensor file name occupancysensorviewmodel kt // =================================================================================== // codelab level 1 // the current status of the occupancy the boolean value is used by the [occupancyfragment] // to react to update ui // todo 1 uncomment the following code blocks // ----------------------------------------------------------------------------------- //private val _occupancy stateflow<boolean> = getoccupancyflowusecase //val occupancy livedata<boolean> // get = _occupancy aslivedata // =================================================================================== // =================================================================================== // codelab level 1 // the current status of the battery the int value is used by the [occupancyfragment] // to react to update fragment's ui // todo 2 uncomment the following code blocks // ----------------------------------------------------------------------------------- //private val _batterystatus mutablestateflow<int> = // getbatpercentremainingusecase as mutablestateflow<int> //val batterystatus livedata<int> // get = _batterystatus aslivedata // =================================================================================== // =================================================================================== // codelab level 1 // triggered by the "occupancy" button in the [occupancyfragment] // [setoccupancyusecase] will update the boolean value of the new occupancy status // todo 3 uncomment the following code blocks // ----------------------------------------------------------------------------------- //viewmodelscope launch { // timber d "current value = ${_occupancy value}" // if _occupancy value { // timber d "set value = false" // setoccupancyusecase false // } else { // timber d "set value = true" // setoccupancyusecase true // } //} // =================================================================================== // =================================================================================== // codelab level 1 // triggered by the "battery" seekbar in the [occupancyfragment] // [batterystatus] store the current status of the battery to indicate the progress // todo 4 uncomment the following code blocks // ----------------------------------------------------------------------------------- //_batterystatus value = progress // =================================================================================== // =================================================================================== // codelab level 1 // triggered by the "battery" seekbar in the [occupancyfragment] // [updatebatteryseekbarprogress] update the current status of the battery to indicate the // progress // [setbatpercentremainingusecase] will update the int value of the new battery status // todo 5 uncomment the following code blocks // ----------------------------------------------------------------------------------- //viewmodelscope launch { // updatebatteryseekbarprogress progress // setbatpercentremainingusecase progress //} // =================================================================================== contact sensorlevel 2 file path feature > sensor > java > com matter virtual device app feature sensor file name contactsensorviewmodel kt // =================================================================================== // codelab level 2 // the current status of the contact the boolean value is used by the [contactsensorfragment] // to react to update ui // todo 1 uncomment the following code blocks // ----------------------------------------------------------------------------------- //private val _statevalue stateflow<boolean> = getstatevalueflowusecase //val statevalue livedata<boolean> // get = _statevalue aslivedata // =================================================================================== // =================================================================================== // codelab level 2 // the current status of the battery the int value is used by the [contactsensorfragment] // to react to update fragment's ui // todo 2 uncomment the following code blocks // ----------------------------------------------------------------------------------- //private val _batterystatus mutablestateflow<int> = // getbatpercentremainingusecase as mutablestateflow<int> //val batterystatus livedata<int> // get = _batterystatus aslivedata // =================================================================================== // =================================================================================== // codelab level 2 // triggered by the "contact" button in the [contactsensorfragment] // [setstatevalueusecase] will update the boolean value of the new contact status // todo 3 uncomment the following code blocks // ----------------------------------------------------------------------------------- //viewmodelscope launch { // timber d "current value = ${_statevalue value}" // if _statevalue value { // timber d "set value = false" // setstatevalueusecase false // } else { // timber d "set value = true" // setstatevalueusecase true // } //} // =================================================================================== // =================================================================================== // codelab level 2 // triggered by the "battery" seekbar in the [contactsensorfragment] // [batterystatus] store the current status of the battery to indicate the progress // todo 4 uncomment the following code blocks // ----------------------------------------------------------------------------------- //_batterystatus value = progress // =================================================================================== // =================================================================================== // codelab level 2 // triggered by the "battery" seekbar in the [contactsensorfragment] // [updatebatteryseekbarprogress] update the current status of the battery to indicate the // progress // [setbatpercentremainingusecase] will update the int value of the new battery status // todo 5 uncomment the following code blocks // ----------------------------------------------------------------------------------- //viewmodelscope launch { // updatebatteryseekbarprogress progress // setbatpercentremainingusecase progress //} // =================================================================================== video playerlevel 2 file path feature > media > java > com matter virtual device app feature media file name videoplayerviewmodel kt // =================================================================================== // codelab level 2 // the current status of the on/off the boolean value is used by the [videoplayerfragment] // to react to update fragment's ui // todo 1 uncomment the following code blocks // ----------------------------------------------------------------------------------- //private val _onoff stateflow<boolean> = getonoffflowusecase //val onoff livedata<boolean> // get = _onoff aslivedata // =================================================================================== // =================================================================================== // codelab level 2 // the current status of the playback state the int value is used by the [videoplayerfragment] // to react to update fragment's ui // todo 2 uncomment the following code blocks // ----------------------------------------------------------------------------------- //private val _playbackstate stateflow<int> = getplaybackstateflowusecase //val playbackstate livedata<int> // get = _playbackstate aslivedata // =================================================================================== // =================================================================================== // codelab level 2 // the current status of the playback speed the int value is used by the [videoplayerfragment] // to react to update fragment's ui // todo 3 uncomment the following code blocks // ----------------------------------------------------------------------------------- //private val _playbackspeed stateflow<int> = getplaybackspeedflowusecase //val playbackspeed livedata<int> // get = _playbackspeed aslivedata // =================================================================================== // =================================================================================== // codelab level 2 // the current status of the key code the enum value is used by the [videoplayerfragment] // to react to update fragment's ui // todo 4 uncomment the following code blocks // ----------------------------------------------------------------------------------- //private val _keycode stateflow<keycode> = getkeycodestateflowusecase //val keycode livedata<keycode> // get = _keycode aslivedata // =================================================================================== // =================================================================================== // codelab level 2 // triggered by the "on/off" button in the [videoplayerfragment] // [setonoffusecase] will update the boolean value of the new on/off status // todo 5 uncomment the following code blocks // ----------------------------------------------------------------------------------- //viewmodelscope launch { // timber d "current value = ${_onoff value}" // if _onoff value { // timber d "set value = false" // setonoffusecase false // } else { // timber d "set value = true" // setonoffusecase true // } //} // =================================================================================== door locklevel 3 file path feature > closure > java > com matter virtual device app feature closure file name doorlockviewmodel kt // =================================================================================== // codelab level 3 // the current status of the lock the boolean value is used by the [doorlockfragment] // to react to update fragment's ui // ----------------------------------------------------------------------------------- // todo 1 copy code below private val _lockstate stateflow<boolean> = getlockstateflowusecase val lockstate livedata<boolean> get = _lockstate aslivedata // ============================================================================== // =================================================================================== // codelab level 3 // the current status of the battery the int value is used by the [doorlockfragment] // to react to update fragment's ui // ----------------------------------------------------------------------------------- // todo 2 copy code below private val _batterystatus mutablestateflow<int> = getbatpercentremainingusecase as mutablestateflow<int> val batterystatus livedata<int> get = _batterystatus aslivedata // ============================================================================== // =================================================================================== // codelab level 3 // triggered by the "lock" button in the [doorlockfragment] // [setlockstateusecase] will update the boolean value of the new lock status // ----------------------------------------------------------------------------------- // todo 3 copy code below viewmodelscope launch { timber d "current lockstate value = ${_lockstate value}" if _lockstate value == lock_state_locked { timber d "set value = unlocked" setlockstateusecase lock_state_unlocked } else { timber d "set value = locked" setlockstateusecase lock_state_locked } } // ============================================================================== // =================================================================================== // codelab level 3 // triggered by the "send alarm" button in the [doorlockfragment] // [sendlockalarmeventusecase] will send alarm event // [setlockstateusecase] will update the boolean value of the unlock status // ----------------------------------------------------------------------------------- // todo 4 copy code below viewmodelscope launch { if !_lockstate value { // if lockstate == locked, send alarm event and change the lockstate to unlocked sendlockalarmeventusecase setlockstateusecase lock_state_unlocked } } // ============================================================================== // =================================================================================== // codelab level 3 // triggered by the "battery" seekbar in the [doorlockfragment] // [batterystatus] store the current status of the battery to indicate the progress // ----------------------------------------------------------------------------------- // todo 5 copy code below _batterystatus value = progress // ============================================================================== // =================================================================================== // codelab level 3 // triggered by the "battery" seekbar in the [doorlockfragment] // [updatebatteryseekbarprogress] update the current status of the battery to indicate the // progress // [setbatpercentremainingusecase] will update the int value of the new battery status // ----------------------------------------------------------------------------------- // todo 6 copy code below viewmodelscope launch { updatebatteryseekbarprogress progress setbatpercentremainingusecase progress } // ============================================================================== extended color lightlevel 3 file path feature > lighting > java > com matter virtual device app feature lighting file name extendedcolorlightviewmodel kt // =================================================================================== // codelab level 3 // the current status of the on/off the boolean value is used by the [extendedcolorlightfragment] // to react to update ui // ----------------------------------------------------------------------------------- // todo 1 copy code below private val _onoff stateflow<boolean> = getonoffflowusecase val onoff livedata<boolean> get = _onoff aslivedata // =================================================================================== // =================================================================================== // codelab level 3 // the current status of the color level the int value is used by the // [extendedcolorlightfragment] // to react to update ui // ----------------------------------------------------------------------------------- // todo 2 copy code below private val _level stateflow<int> = getlevelflowusecase val level livedata<int> get = _level aslivedata // =================================================================================== // =================================================================================== // codelab level 3 // the current status of the color the enum value is used by the [extendedcolorlightfragment] // to react to update ui // ----------------------------------------------------------------------------------- // todo 3 copy code below private val _currenthue stateflow<int> = getcurrenthueflowusecase private val _currentsaturation stateflow<int> = getcurrentsaturationflowusecase val currentcolor livedata<hsvcolor> = combine _currenthue, _currentsaturation { currenthue, currentsaturation -> hsvcolor currenthue, currentsaturation } aslivedata // =================================================================================== // =================================================================================== // codelab level 3 // the current status of the color temperature the int value is used by the // [extendedcolorlightfragment] // to react to update ui // ----------------------------------------------------------------------------------- // todo 4 copy code below private val _colortemperature stateflow<int> = getcolortemperatureflowusecase val colortemperature livedata<int> get = _colortemperature aslivedata // =================================================================================== // =================================================================================== // codelab level 3 // triggered by the "on/off" button in the [extendedcolorlightfragment] // [setonoffusecase] will update the boolean value of the new on/off status // ----------------------------------------------------------------------------------- // todo 5 copy code below viewmodelscope launch { timber d "current value = ${_onoff value}" if _onoff value { timber d "set value = false" setonoffusecase false } else { timber d "set value = true" setonoffusecase true } } // =================================================================================== window coveringlevel 4 file path feature > closure > java > com matter virtual device app feature closure file name windowcoveringviewmodel kt // =================================================================================== // codelab level 4 // the current status of the position/operation the enum value is used by the // [windowcoveringfragment] // to react to update fragment's ui // ----------------------------------------------------------------------------------- // todo 1 copy code below val windowcoveringstatus livedata<windowcoveringstatus> = combine _currentposition, _operationalstatus { currentposition, operationalstatus -> windowcoveringstatus currentposition, operationalstatus } aslivedata // =================================================================================== // =================================================================================== // codelab level 4 // the current status of the battery the int value is used by the [windowcoveringfragment] // to react to update fragment's ui // ----------------------------------------------------------------------------------- // todo 2 copy code below private val _batterystatus mutablestateflow<int> = getbatpercentremainingusecase as mutablestateflow<int> val batterystatus livedata<int> get = _batterystatus aslivedata // =================================================================================== // =================================================================================== // codelab level 4 // triggered by the "windowshade" seekbar in the [windowcoveringfragment] // [settargetpositionusecase] will update the int value of the new target position status // ----------------------------------------------------------------------------------- // todo 3 copy code below viewmodelscope launch { timber d "target position = $percentage" settargetpositionusecase percentage } // =================================================================================== // =================================================================================== // codelab level 4 // triggered by the "open" button in the [fragment_window_covering xml] // [settargetpositionusecase] will update the int value of the open position 100 status // ----------------------------------------------------------------------------------- // todo 4 copy code below viewmodelscope launch { timber d "target position = 100" settargetpositionusecase 100 } // =================================================================================== // =================================================================================== // codelab level 4 // triggered by the "close" button in the [fragment_window_covering xml] // [settargetpositionusecase] will update the int value of the close position 0 status // ----------------------------------------------------------------------------------- // todo 5 copy code below viewmodelscope launch { settargetpositionusecase 0 } // =================================================================================== // =================================================================================== // codelab level 4 // triggered by the "pause" button in the [fragment_window_covering xml] // [settargetpositionusecase] will update the int value of the pause position status // ----------------------------------------------------------------------------------- // todo 6 copy code below viewmodelscope launch { timber d "current position = ${_currentposition value}, target position ${_targetposition value}" if _currentposition value != _targetposition value { settargetpositionusecase _currentposition value } } // =================================================================================== // =================================================================================== // codelab level 4 // triggered by the "battery" seekbar in the [windowcoveringfragment] // [batterystatus] store the current status of the battery to indicate the progress // ----------------------------------------------------------------------------------- // todo 7 copy code below _batterystatus value = progress // =================================================================================== // =================================================================================== // codelab level 4 // triggered by the "battery" seekbar in the [windowcoveringfragment] // [updatebatteryseekbarprogress] update the current status of the battery to indicate the // progress // [setbatpercentremainingusecase] will update the int value of the new battery status // ----------------------------------------------------------------------------------- // todo 8 copy code below viewmodelscope launch { updatebatteryseekbarprogress progress setbatpercentremainingusecase progress } // =================================================================================== thermostatlevel 5 file path feature > hvac > java > com matter virtual device app feature hvac file name thermostatviewmodel kt // =================================================================================== // codelab level 5 // the current status of the temperature the int value is used by the [thermostatfragment] // to react to update fragment's ui // ----------------------------------------------------------------------------------- // todo 1 copy code below private val _temperature mutablestateflow<int> = getlocaltemperatureusecase as mutablestateflow<int> val temperature livedata<int> get = _temperature aslivedata // =================================================================================== // =================================================================================== // codelab level 5 // the current status of the humidity the int value is used by the [thermostatfragment] // to react to update fragment's ui // ----------------------------------------------------------------------------------- // todo 2 copy code below private val _humidity mutablestateflow<int> = getrelativehumidityusecase as mutablestateflow<int> val humidity livedata<int> get = _humidity aslivedata // =================================================================================== // =================================================================================== // codelab level 5 // the current status of the system mode the enum value is used by the [thermostatfragment] // to react to update fragment's ui // ----------------------------------------------------------------------------------- // todo 3 copy code below private val _systemmode stateflow<thermostatsystemmode> = getsystemmodeflowusecase val systemmode livedata<thermostatsystemmode> get = _systemmode aslivedata // =================================================================================== // =================================================================================== // codelab level 5 // the current status of the fan mode the enum value is used by the [thermostatfragment] // to react to update fragment's ui // ----------------------------------------------------------------------------------- // todo 4 copy code below private val _fanmode stateflow<fancontrolfanmode> = getfanmodeflowusecase val fanmode livedata<fancontrolfanmode> get = _fanmode aslivedata // =================================================================================== // =================================================================================== // codelab level 5 // the current status of the cooling setpoint the int value is used by the [thermostatfragment] // to react to update fragment's ui // ----------------------------------------------------------------------------------- // todo 5 copy code below private val _occupiedcoolingsetpoint stateflow<int> = getoccupiedcoolingsetpointflowusecase val occupiedcoolingsetpoint livedata<int> get = _occupiedcoolingsetpoint aslivedata // =================================================================================== // =================================================================================== // codelab level 5 // the current status of the heating setpoint the int value is used by the [thermostatfragment] // to react to update fragment's ui // ----------------------------------------------------------------------------------- // todo 6 copy code below private val _occupiedheatingsetpoint stateflow<int> = getoccupiedheatingsetpointflowusecase val occupiedheatingsetpoint livedata<int> get = _occupiedheatingsetpoint aslivedata // =================================================================================== // =================================================================================== // codelab level 5 // the current status of the battery the int value is used by the [thermostatfragment] // to react to update fragment's ui // ----------------------------------------------------------------------------------- // todo 7 copy code below private val _batterystatus mutablestateflow<int> = getbatpercentremainingusecase as mutablestateflow<int> val batterystatus livedata<int> get = _batterystatus aslivedata // =================================================================================== // =================================================================================== // codelab level 5 // triggered by the "humidity" seekbar in the [thermostatfragment] // [humidity] store the current status of the humidity to indicate the progress // ----------------------------------------------------------------------------------- // todo 8 copy code below _humidity value = progress * 100 // =================================================================================== // =================================================================================== // codelab level 5 // triggered by the "humidity" seekbar in the [thermostatfragment] // [updatehumidityseekbarprogress] update the current status of the humidity to indicate the // progress // [setrelativehumidityusecase] will update the int value of the new humidity status [0 100] // * 100 // ----------------------------------------------------------------------------------- // todo 9 copy code below viewmodelscope launch { updatehumidityseekbarprogress progress setrelativehumidityusecase progress * 100 } // =================================================================================== // =================================================================================== // codelab level 5 // triggered by the "temperature" seekbar in the [thermostatfragment] // [temperature] store the current status of the temperature to indicate the progress // ----------------------------------------------------------------------------------- // todo 10 copy code below _temperature value = progress * 100 // =================================================================================== // =================================================================================== // codelab level 5 // triggered by the "temperature" seekbar in the [thermostatfragment] // [updatetemperatureseekbarprogress] update the current status of the temperature to indicate // the progress // [setlocaltemperatureusecase] will update the int value of the new temperature status // [value] * 100 // ----------------------------------------------------------------------------------- // todo 11 copy code below viewmodelscope launch { updatetemperatureseekbarprogress progress setlocaltemperatureusecase progress * 100 } // ==================================================================================== // =================================================================================== // codelab level 5 // triggered by the "battery" seekbar in the [thermostatfragment] // [batterystatus] store the current status of the battery to indicate the progress // ----------------------------------------------------------------------------------- // todo 12 copy code below _batterystatus value = progress // ==================================================================================== // =================================================================================== // codelab level 5 // triggered by the "battery" seekbar in the [thermostatfragment] // [updatebatteryseekbarprogress] update the current status of the battery to indicate the // progress // [setbatpercentremainingusecase] will update the int value of the new battery status // ----------------------------------------------------------------------------------- // todo 13 copy code below viewmodelscope launch { updatebatteryseekbarprogress progress setbatpercentremainingusecase progress } // ==================================================================================== // =================================================================================== // codelab level 5 // triggered by the "systemmode" popup in the [thermostatfragment] // [setsystemmodeusecase] will update the enum value of the new system mode status // ----------------------------------------------------------------------------------- // todo 14 copy code below viewmodelscope launch { setsystemmodeusecase systemmode } // ==================================================================================== // =================================================================================== // codelab level 5 // triggered by the "fanmode" popup in the [thermostatfragment] // [setfanmodeusecase] will update the enum value of the new fan mode status // ----------------------------------------------------------------------------------- // todo 15 copy code below viewmodelscope launch { setfanmodeusecase fanmode } // ==================================================================================== // =================================================================================== // codelab level 5 // triggered by the "heating plus" button in the [fragment_thermostat xml] // [setoccupiedheatingsetpointusecase] will update the int value of the +1 degree [degree] * // 100 // ----------------------------------------------------------------------------------- // todo 16 copy code below viewmodelscope launch { val nextvalue = _occupiedheatingsetpoint value + 100 timber d "current value = ${_occupiedheatingsetpoint value} set value = $nextvalue" setoccupiedheatingsetpointusecase nextvalue } // ==================================================================================== // =================================================================================== // codelab level 5 // triggered by the "heating minus" button in the [fragment_thermostat xml] // [setoccupiedheatingsetpointusecase] will update the int value of the -1 degree [degree] * // 100 // ----------------------------------------------------------------------------------- // todo 17 copy code below viewmodelscope launch { val nextvalue = _occupiedheatingsetpoint value - 100 timber d "current value = ${_occupiedheatingsetpoint value} set value = $nextvalue" setoccupiedheatingsetpointusecase nextvalue } // ==================================================================================== // =================================================================================== // codelab level 5 // triggered by the "cooling plus" button in the [fragment_thermostat xml] // [setoccupiedcoolingsetpointusecase] will update the int value of the +1 degree [degree] * // 100 // ----------------------------------------------------------------------------------- // todo 18 copy code below viewmodelscope launch { val nextvalue = _occupiedcoolingsetpoint value + 100 timber d "current value = ${_occupiedcoolingsetpoint value} set value = $nextvalue" setoccupiedcoolingsetpointusecase nextvalue } // ==================================================================================== // =================================================================================== // codelab level 5 // triggered by the "cooling minus" button in the [fragment_thermostat xml] // [setoccupiedcoolingsetpointusecase] will update the int value of the -1 degree [degree] * // 100 // ----------------------------------------------------------------------------------- // todo 19 copy code below viewmodelscope launch { val nextvalue = _occupiedcoolingsetpoint value - 100 timber d "current value = ${_occupiedcoolingsetpoint value} set value = $nextvalue" setoccupiedcoolingsetpointusecase nextvalue } // ==================================================================================== noteyou can find related files in android studio by going to edit menu> find > find in files and entering the keyword "codelab" observe cluster value next, use the observe function to keep track whenever there is a change in the cluster value occupancy sensorlevel 1 file path feature > sensor > java > com matter virtual device app feature sensor file name occupancysensorfragment kt // =================================================================================== // codelab level 1 // trigger the processing for updating new occupancy state of the virtual device // todo 1 uncomment the following code blocks // ----------------------------------------------------------------------------------- //binding occupancybutton setonclicklistener { viewmodel onclickbutton } // =================================================================================== // =================================================================================== // codelab level 1 // [onprogresschanged] will update the fragment's ui via viewmodel livedata // [onstoptrackingtouch] will trigger the processing for updating new battery state of the // virtual device // todo 2 uncomment the following code blocks // ----------------------------------------------------------------------------------- //binding occupancysensorbatterylayout titletext text = getstring r string battery //binding occupancysensorbatterylayout seekbardata = // seekbardata progress = viewmodel batterystatus //binding occupancysensorbatterylayout seekbar setonseekbarchangelistener // object seekbar onseekbarchangelistener { // override fun onprogresschanged seekbar seekbar, progress int, fromuser boolean { // viewmodel updatebatteryseekbarprogress progress // } // // override fun onstarttrackingtouch seekbar seekbar {} // // override fun onstoptrackingtouch seekbar seekbar { // viewmodel updatebatterystatustocluster seekbar progress // } // } // // =================================================================================== // =================================================================================== // codelab level 1 // observer on the current occupancy status and react on the fragment's ui // todo 3 uncomment the following code blocks // ----------------------------------------------------------------------------------- //viewmodel occupancy observe viewlifecycleowner { // if it { // binding occupancyvaluetext text = getstring r string occupancy_state_occupied // binding occupancybutton setimageresource r drawable ic_occupied // } else { // binding occupancyvaluetext text = getstring r string occupancy_state_unoccupied // binding occupancybutton setimageresource r drawable ic_unoccupied // } //} // =================================================================================== // =================================================================================== // codelab level 1 // observer on the current battery status and react on the fragment's ui // todo 4 uncomment the following code blocks // ----------------------------------------------------------------------------------- //viewmodel batterystatus observe viewlifecycleowner { // val text string = getstring r string battery_format, it // binding occupancysensorbatterylayout valuetext text = // html fromhtml text, html from_html_mode_legacy //} // =================================================================================== contact sensorlevel 2 file path feature > sensor > java > com matter virtual device app feature sensor file name contactsensorfragment kt // =================================================================================== // codelab level 2 // trigger the processing for updating new contact state of the virtual device // todo 1 uncomment the following code blocks // ----------------------------------------------------------------------------------- //binding contactbutton setonclicklistener { viewmodel onclickbutton } // =================================================================================== /** battery layout */ // =================================================================================== // codelab level 2 // [onprogresschanged] will update the fragment's ui via viewmodel livedata // [onstoptrackingtouch] will trigger the processing for updating new battery state of the // virtual device // todo 2 uncomment the following code blocks // ----------------------------------------------------------------------------------- //binding contactsensorbatterylayout titletext text = getstring r string battery //binding contactsensorbatterylayout seekbardata = seekbardata progress = viewmodel batterystatus //binding contactsensorbatterylayout seekbar setonseekbarchangelistener // object seekbar onseekbarchangelistener { // override fun onprogresschanged seekbar seekbar, progress int, fromuser boolean { // viewmodel updatebatteryseekbarprogress progress // } // // override fun onstarttrackingtouch seekbar seekbar {} // // override fun onstoptrackingtouch seekbar seekbar { // viewmodel updatebatterystatustocluster seekbar progress // } // } // // =================================================================================== // =================================================================================== // codelab level 2 // observer on the current contact status and react on the fragment's ui // todo 3 uncomment the following code blocks // ----------------------------------------------------------------------------------- //viewmodel statevalue observe viewlifecycleowner { // if it { // binding contactvaluetext text = getstring r string contact_state_close // binding contactbutton setimageresource r drawable ic_unoccupied // } else { // binding contactvaluetext text = getstring r string contact_state_open // binding contactbutton setimageresource r drawable ic_occupied // } //} // =================================================================================== // =================================================================================== // codelab level 2 // observer on the current battery status and react on the fragment's ui // todo 4 uncomment the following code blocks // ----------------------------------------------------------------------------------- //viewmodel batterystatus observe viewlifecycleowner { // val text string = getstring r string battery_format, it // binding contactsensorbatterylayout valuetext text = // html fromhtml text, html from_html_mode_legacy } // =================================================================================== video playerlevel 2 file path feature > media > java > com matter virtual device app feature media file name videoplayerfragment kt // =================================================================================== // codelab level 2 // [buttondata] observer on the current on/off status and react on the fragment's ui // [onclicklistener] trigger the processing for updating new on/off state of the virtual device // todo 1 uncomment the following code blocks // ----------------------------------------------------------------------------------- //binding videoplayeronofflayout buttondata = // buttondata // onoff = viewmodel onoff, // ontext = r string on_off_switch_power_on, // offtext = r string on_off_switch_power_off // //binding videoplayeronofflayout button setonclicklistener { viewmodel onclickbutton } // =================================================================================== // =================================================================================== // codelab level 2 // observer on the current playback status and react on the fragment's ui // todo 2 uncomment the following code blocks // ----------------------------------------------------------------------------------- //viewmodel playbackstate observe viewlifecycleowner { state -> // val statetext = convertplaybackstatetostring state // timber d "playbackstate $state $statetext " // binding videoplayerstatelayout valuetext text = statetext //} // =================================================================================== // =================================================================================== // codelab level 2 // observer on the current playback speed and react on the fragment's ui // todo 3 uncomment the following code blocks // ----------------------------------------------------------------------------------- //viewmodel playbackspeed observe viewlifecycleowner { speed -> // binding videoplayerspeedlayout valuetext text = speed tostring //} // =================================================================================== // =================================================================================== // codelab level 2 // observer on the current key code and react on the fragment's ui // todo 4 uncomment the following code blocks // ----------------------------------------------------------------------------------- //viewmodel keycode observe viewlifecycleowner { keycode -> // binding videoplayerkeypadlayout valuetext text = keycode value //} // =================================================================================== door locklevel 3 file path feature > closure > java > com matter virtual device app feature closure file name doorlockfragment kt // =================================================================================== // codelab level 3 // [buttondata] observer on the current lock status and react on the fragment's ui // [onclicklistener] trigger the processing for updating new lock state of the virtual device // ----------------------------------------------------------------------------------- // todo 1 copy code below binding doorlockonofflayout buttondata = buttondata onoff = viewmodel lockstate, ontext = r string door_lock_unlocked, offtext = r string door_lock_locked binding doorlockonofflayout button setonclicklistener { viewmodel onclickbutton } // =================================================================================== // =================================================================================== // codelab level 3 // trigger the processing for sending alarm event // ----------------------------------------------------------------------------------- // todo 2 copy code below binding doorlocksendalarmlayout button setonclicklistener { viewmodel onclicksendlockalarmeventbutton } // =================================================================================== // =================================================================================== // codelab level 3 // [onprogresschanged] will update the fragment's ui via viewmodel livedata // [onstoptrackingtouch] will trigger the processing for updating new battery state of the // virtual device // ----------------------------------------------------------------------------------- // todo 3 copy code below binding doorlockbatterylayout titletext text = getstring r string battery binding doorlockbatterylayout seekbardata = seekbardata progress = viewmodel batterystatus binding doorlockbatterylayout seekbar setonseekbarchangelistener object seekbar onseekbarchangelistener { override fun onprogresschanged seekbar seekbar, progress int, fromuser boolean { viewmodel updatebatteryseekbarprogress progress } override fun onstarttrackingtouch seekbar seekbar {} override fun onstoptrackingtouch seekbar seekbar { viewmodel updatebatterystatustocluster seekbar progress } } // =================================================================================== // =================================================================================== // codelab level 3 // observer on the current battery status and react on the fragment's ui // ----------------------------------------------------------------------------------- // todo 4 copy code below viewmodel batterystatus observe viewlifecycleowner { val text string = getstring r string battery_format, it binding doorlockbatterylayout valuetext text = html fromhtml text, html from_html_mode_legacy } // =================================================================================== extended color lightlevel 3 file path feature > lighting > java > com matter virtual device app feature lighting file name extendedcolorlightfragment kt // =================================================================================== // codelab level 3 // [buttondata] observer on the current on/off status and react on the fragment's ui // [onclicklistener] trigger the processing for updating new on/off state of the virtual device // ----------------------------------------------------------------------------------- // todo 1 copy code below binding extendedcolorlightonofflayout buttondata = buttondata onoff = viewmodel onoff, ontext = r string on_off_switch_power_on, offtext = r string on_off_switch_power_off binding extendedcolorlightonofflayout button setonclicklistener { viewmodel onclickbutton } // =================================================================================== // =================================================================================== // codelab level 3 // observer on the current color level status and react on the fragment's ui // ----------------------------------------------------------------------------------- // todo 2 copy code below viewmodel level observe viewlifecycleowner { // min 2 1% , max 255 100% val level int = it tofloat / 100 * 255 toint timber d "level $it" // if level value is 0, user can't distinguish the color // so, set it to half value + half of max binding extendedcolorlightcolorlayout colorboard drawable? alpha = level / 2 + 127 } // =================================================================================== // =================================================================================== // codelab level 3 // observer on the current color status and react on the fragment's ui // ----------------------------------------------------------------------------------- // todo 3 copy code below viewmodel currentcolor observe viewlifecycleowner { hsvcolor -> val rgbcolor int = colorcontrolutil hue2rgb hsvcolor currenthue tofloat , hsvcolor currentsaturation tofloat timber d "currenthue ${hsvcolor currenthue},currentsaturation ${hsvcolor currentsaturation}" timber d "color #${integer tohexstring rgbcolor }" var level int? = binding extendedcolorlightcolorlayout colorboard drawable? alpha if level == null level = 255 timber d "level $level" binding extendedcolorlightcolorlayout colorboard setimagedrawable bitmapdrawable resources, colorcontrolutil colorboard rgbcolor } // =================================================================================== // =================================================================================== // codelab level 3 // observer on the current color temperature status and react on the fragment's ui // ----------------------------------------------------------------------------------- // todo 4 copy code below viewmodel colortemperature observe viewlifecycleowner { // min 2580k 2577k , max 7050k 7042k val colortemperature int = 1000000 / it val rgbcolor int = colorcontrolutil kelvin2rgb colortemperature timber d "color temperature $colortemperature $it" timber d "color #${integer tohexstring rgbcolor }" binding extendedcolorlightcolorlayout colorboard setimagedrawable bitmapdrawable resources, colorcontrolutil colorboard rgbcolor } // =================================================================================== window coveringlevel 4 file path feature > closure > java > com matter virtual device app feature closure file name windowcoveringfragment kt // =================================================================================== // codelab level 4 // [onprogresschanged] will update the fragment's ui via viewmodel livedata // [onstoptrackingtouch] will trigger the processing for updating new windowshade state of the // virtual device // ----------------------------------------------------------------------------------- // todo 1 copy code below binding windowcoveringwindowshadeseekbar setonseekbarchangelistener object seekbar onseekbarchangelistener { override fun onprogresschanged seekbar seekbar, progress int, fromuser boolean { val targetpercentage = seekbar progress val text string = getstring r string window_covering_window_shade_format, targetpercentage val percentagetextview = binding windowcoveringwindowshadevaluetext percentagetextview text = html fromhtml text, html from_html_mode_legacy } override fun onstarttrackingtouch seekbar seekbar {} override fun onstoptrackingtouch seekbar seekbar { viewmodel stopmotion seekbar progress } } // ======================================================================================================= // =================================================================================== // codelab level 4 // [onprogresschanged] will update the fragment's ui via viewmodel livedata // [onstoptrackingtouch] will trigger the processing for updating new battery state of the // virtual device // ----------------------------------------------------------------------------------- // todo 2 copy code below binding windowcoveringbatterylayout titletext text = getstring r string battery binding windowcoveringbatterylayout seekbardata = seekbardata progress = viewmodel batterystatus binding windowcoveringbatterylayout seekbar setonseekbarchangelistener object seekbar onseekbarchangelistener { override fun onprogresschanged seekbar seekbar, progress int, fromuser boolean { viewmodel updatebatteryseekbarprogress progress } override fun onstarttrackingtouch seekbar seekbar {} override fun onstoptrackingtouch seekbar seekbar { viewmodel updatebatterystatustocluster seekbar progress } } // ======================================================================================================= // =================================================================================== // codelab level 4 // observer on the current position/operation status and react on the fragment's ui // ----------------------------------------------------------------------------------- // todo 3 copy code below viewmodel windowcoveringstatus observe viewlifecycleowner { status -> timber d "currentposition ${status currentposition},operationalstatus ${status operationalstatus}" binding windowcoveringwindowshadeseekbar progress = status currentposition val text string = getstring r string window_covering_window_shade_format, status currentposition binding windowcoveringwindowshadevaluetext text = html fromhtml text, html from_html_mode_legacy when status operationalstatus { 0 -> { when status currentposition { 0 -> { binding windowcoveringoperationalstatustext settext r string window_covering_closed } 100 -> { binding windowcoveringoperationalstatustext settext r string window_covering_open } else -> { binding windowcoveringoperationalstatustext settext r string window_covering_partially_open } } } 1 -> { binding windowcoveringoperationalstatustext settext r string window_covering_opening } 2 -> { binding windowcoveringoperationalstatustext settext r string window_covering_closing } else -> {} } } // ======================================================================================================= // =================================================================================== // codelab level 4 // observer on the current battery status and react on the fragment's ui // ----------------------------------------------------------------------------------- // todo 4 copy code below viewmodel batterystatus observe viewlifecycleowner { val text string = getstring r string battery_format, it binding windowcoveringbatterylayout valuetext text = html fromhtml text, html from_html_mode_legacy } // ======================================================================================================= thermostatlevel 5 file path feature > hvac > java > com matter virtual device app feature hvac file name themostatfragment kt // =================================================================================== // codelab level 5 // [onprogresschanged] will update the fragment's ui via viewmodel livedata // [onstoptrackingtouch] will trigger the processing for updating new temperature state of the // virtual device // ----------------------------------------------------------------------------------- // todo 1 copy code below binding thermostattemperatureseekbar setonseekbarchangelistener object seekbar onseekbarchangelistener { override fun onprogresschanged seekbar seekbar, progress int, fromuser boolean { viewmodel updatetemperatureseekbarprogress progress } override fun onstarttrackingtouch seekbar seekbar {} override fun onstoptrackingtouch seekbar seekbar { viewmodel updatetemperaturetocluster seekbar progress } } // =================================================================================== // =================================================================================== // codelab level 5 // [onprogresschanged] will update the fragment's ui via viewmodel livedata // [onstoptrackingtouch] will trigger the processing for updating new humidity state of the // virtual device // ----------------------------------------------------------------------------------- // todo 2 copy code below binding humiditysensorhumidityseekbar setonseekbarchangelistener object seekbar onseekbarchangelistener { override fun onprogresschanged seekbar seekbar, progress int, fromuser boolean { viewmodel updatehumidityseekbarprogress progress } override fun onstarttrackingtouch seekbar seekbar {} override fun onstoptrackingtouch seekbar seekbar { viewmodel updatehumiditytocluster seekbar progress } } // =================================================================================== // =================================================================================== // codelab level 5 // [onprogresschanged] will update the fragment's ui via viewmodel livedata // [onstoptrackingtouch] will trigger the processing for updating new battery state of the // virtual device // ----------------------------------------------------------------------------------- // todo 3 copy code below binding thermostatbatterylayout titletext text = getstring r string battery binding thermostatbatterylayout seekbardata = seekbardata progress = viewmodel batterystatus binding thermostatbatterylayout seekbar setonseekbarchangelistener object seekbar onseekbarchangelistener { override fun onprogresschanged seekbar seekbar, progress int, fromuser boolean { viewmodel updatebatteryseekbarprogress progress } override fun onstarttrackingtouch seekbar seekbar {} override fun onstoptrackingtouch seekbar seekbar { viewmodel updatebatterystatustocluster seekbar progress } } // =================================================================================== // =================================================================================== // codelab level 5 // observer on the current temperature status and react on the fragment's ui // ----------------------------------------------------------------------------------- // todo 4 copy code below viewmodel temperature observe viewlifecycleowner { val celsiustemp float = it tofloat / 100 val celsiustext string = getstring r string temperature_celsius_format, celsiustemp binding thermostattemperaturecelsiusvaluetext text = html fromhtml celsiustext, html from_html_mode_legacy val fahrenheittemp float = it tofloat / 100 * 9 / 5 + 32 val fahrenheittext string = getstring r string temperature_fahrenheit_format, fahrenheittemp binding thermostattemperaturefahrenheitvaluetext text = html fromhtml fahrenheittext, html from_html_mode_legacy binding thermostattemperatureseekbar progress = celsiustemp toint } // ========================================================================================== // =================================================================================== // codelab level 5 // observer on the current fan mode status and react on the fragment's ui // ----------------------------------------------------------------------------------- // todo 5 copy code below viewmodel fanmode observe viewlifecycleowner { timber d "fanmode $it" this fanmode = it binding fancontrolfanmodelayout valuetext text = convertfanmodetostring it } // ========================================================================================== // =================================================================================== // codelab level 5 // observer on the current heating setpoint and react on the fragment's ui // ----------------------------------------------------------------------------------- // todo 6 copy code below viewmodel occupiedheatingsetpoint observe viewlifecycleowner { val celsiustemp float = it tofloat / 100 val celsiustext string = getstring r string temperature_celsius_format, celsiustemp binding thermostatsettemperatureheatingcelsiusvaluetext text = html fromhtml celsiustext, html from_html_mode_legacy val fahrenheittemp float = it tofloat / 100 * 9 / 5 + 32 val fahrenheittext string = getstring r string temperature_fahrenheit_format, fahrenheittemp binding thermostatsettemperatureheatingfahrenheitvaluetext text = html fromhtml fahrenheittext, html from_html_mode_legacy } // =================================================================================== // =================================================================================== // codelab level 5 // observer on the current cooling setpoint and react on the fragment's ui // ----------------------------------------------------------------------------------- // todo 7 copy code below viewmodel occupiedcoolingsetpoint observe viewlifecycleowner { val celsiustemp float = it tofloat / 100 val celsiustext string = getstring r string temperature_celsius_format, celsiustemp binding thermostatsettemperaturecoolingcelsiusvaluetext text = html fromhtml celsiustext, html from_html_mode_legacy val fahrenheittemp float = it tofloat / 100 * 9 / 5 + 32 val fahrenheittext string = getstring r string temperature_fahrenheit_format, fahrenheittemp binding thermostatsettemperaturecoolingfahrenheitvaluetext text = html fromhtml fahrenheittext, html from_html_mode_legacy } // =================================================================================== // =================================================================================== // codelab level 5 // observer on the current system mode status and react on the fragment's ui // ----------------------------------------------------------------------------------- // todo 8 copy code below viewmodel systemmode observe viewlifecycleowner { timber d "systemmode $it" this systemmode = it binding thermostatsystemmodelayout valuetext text = convertsystemmodetostring it } // =================================================================================== // =================================================================================== // codelab level 5 // observer on the current humidity status and react on the fragment's ui // ----------------------------------------------------------------------------------- // todo 9 copy code below viewmodel humidity observe viewlifecycleowner { val humidity int = it / 100 val humiditytext string = getstring r string humidity_format, humidity binding humiditysensorhumiditypercentagevaluetext text = html fromhtml humiditytext, html from_html_mode_legacy binding humiditysensorhumidityseekbar progress = humidity } // =================================================================================== // =================================================================================== // codelab level 5 // observer on the current battery status and react on the fragment's ui // ----------------------------------------------------------------------------------- // todo 10 copy code below viewmodel batterystatus observe viewlifecycleowner { val text string = getstring r string battery_format, it binding thermostatbatterylayout valuetext text = html fromhtml text, html from_html_mode_legacy } // =================================================================================== // =================================================================================== // codelab level 5 // trigger the processing for setting system mode // ----------------------------------------------------------------------------------- // todo 11 copy code below alertdialog builder requirecontext settitle r string thermostat_mode setsinglechoiceitems modelist, convertsystemmodetoindex this systemmode { dialog, which -> timber d "thermostat mode set $which ${modelist[which]} " viewmodel setsystemmode convertindextosystemmode which dialog dismiss } setnegativebutton r string cancel, null show // =================================================================================== // =================================================================================== // codelab level 5 // trigger the processing for setting fan mode // ----------------------------------------------------------------------------------- // todo 12 copy code below alertdialog builder requirecontext settitle r string fan_control_fan_mode setsinglechoiceitems modelist, convertfanmodetoindex this fanmode { dialog, which -> timber d "fan mode set $which ${modelist[which]} " viewmodel setfanmode convertindextofanmode which dialog dismiss } setnegativebutton r string cancel, null show // =================================================================================== build and run the virtual device app to build and run your app, follow these steps using a usb cable, connect your mobile device the minimum os requirement is android 8 0 oreo select the sample virtual device app from the run configurations menu in the android studio then, select the connected device in the target device menu click run you can see the device you created in the matter virtual device app onboard and control the virtual device via the smartthings app onboard to onboard the virtual device select and set up the virtual device type you created click save click start to show the qr code for onboarding then, go to the smartthings app and click the + button then, onboard the virtual device by scanning its qr code control by smartthings app in the smartthings app, control the virtual device by using its various functions such as on and off for switch contribute to matter open source optional notethis step is optional, but you can proceed if you want to know how to contribute your code to matter open source to contribute to matter open source, you need to have the latest code therefore, apart from the project files provided by this code lab activity, you should fork and modify the latest code from matter open source project matter follows the "fork-and-pull" model for accepting contributions to do this sign in or sign up to github fork the matter repository by clicking fork on the web ui for each new feature, clone your fork to the local pc and create a working branch $ git clone https //github com/<username>/connectedhomeip git $ git checkout –b <branch-name> before running the build command, source the environment setup script activate sh at the top level this script takes care of downloading gn, ninja, and setting up a python environment with libraries used to build and test $ source scripts/activate sh build the virtual device app using the build_example py $ /scripts/build/build_examples py --target android-arm64-virtual-device-app build add each modified file to include in the commit then, create a commit $ git add <filename1> <filename1> $ git commit –s noteto contribute to the open source, you must check the integrity of the code for this, checking using restyle is recommended push to your github fork $ git push origin <branch-name> then, submit your pull request by clicking contribute > open pull request on the web ui write a description of the problem, change overview, and test then, sign the contributor license agreement cla so a reviewer can automatically be assigned click open pull request tipsee contributing to matter for more information you're done! congratulations! you have successfully achieved the goal of this code lab topic now, you can create a matter-compatible virtual device and contribute your code to matter open source by yourself! if you're having trouble, you may download this file matter virtual device complete code 11 49 mb learn more by going to smartthings matter libraries
tutorials health, galaxy watch, mobile
blogthe samsung privileged health sdk enables your application to collect vital signs and other health parameters tracked on galaxy watch running wear os powered by samsung. the tracked data can be displayed immediately or retained for later analysis. some kinds of tracked data, such as batching data, are impractical to display on a watch screen in real-time, so it is common to store the data in a database or server solution or show them on the larger screen of a mobile device. this blog demonstrates how to develop 2 connected sample applications. a watch application uses the samsung privileged health sdk to collect heart rate tracker data, then uses the wearable data layer api to transmit it to a companion application on the user’s android mobile device, which displays the data as a simple list on its screen. you can follow along with the demonstration by downloading the sample application project. to test the applications, you need a galaxy watch4 (or higher model) and a connected android mobile device. creating the application project the application project consists of a wearable module for the watch, and a mobile module for android mobile devices: in android studio, select open file > new > new project. select wear os > empty wear app and click next. new wear app define the project details. project details to create a companion mobile application for the watch application, check the pair with empty phone app box. notemake sure that the application id is identical for both modules in their “build.gradle” files. for more information about creating multi-module projects, see from wrist to hand: develop a companion app for your wearable application. implementing the watch application the watch application ui has 2 buttons. the start/stop button controls heart data tracking, and the send button transfers the collected data to the connected mobile device. the screen consists of a heart rate field and 4 ibi value fields, since there can be up to 4 ibi values in a single tracking result. watch application ui track and extract heart rate data when the user taps the start button on the wearable application ui, the starttracking() function from the mainviewmodel class is invoked. the application must check that the galaxy watch supports the heart rate tracking capability that we want to implement, as the supported capabilities depend on the device model and software version. retrieve the list of supported health trackers with the trackingcapability.supporthealthtrackertypes of the healthtrackingservice class: override fun hascapabilities(): boolean { log.i(tag, "hascapabilities()") healthtrackingservice = healthtrackingserviceconnection.gethealthtrackingservice() val trackers: list<healthtrackertype> = healthtrackingservice!!.trackingcapability.supporthealthtrackertypes return trackers.contains(trackingtype) } to track the heart rate values on the watch, read the flow of values received in the ondatareceived() listener: @experimentalcoroutinesapi override suspend fun track(): flow<trackermessage> = callbackflow { val updatelistener = object : healthtracker.trackereventlistener { override fun ondatareceived(datapoints: mutablelist<datapoint>) { for (datapoint in datapoints) { var trackeddata: trackeddata? = null val hrvalue = datapoint.getvalue(valuekey.heartrateset.heart_rate) val hrstatus = datapoint.getvalue(valuekey.heartrateset.heart_rate_status) if (ishrvalid(hrstatus)) { trackeddata = trackeddata() trackeddata.hr = hrvalue log.i(tag, "valid hr: $hrvalue") } else { coroutinescope.runcatching { trysendblocking(trackermessage.trackerwarningmessage(geterror(hrstatus.tostring()))) } } val validibilist = getvalidibilist(datapoint) if (validibilist.size > 0) { if (trackeddata == null) trackeddata = trackeddata() trackeddata.ibi.addall(validibilist) } if ((ishrvalid(hrstatus) || validibilist.size > 0) && trackeddata != null) { coroutinescope.runcatching { trysendblocking(trackermessage.datamessage(trackeddata)) } } if (trackeddata != null) { validhrdata.add(trackeddata) } } trimdatalist() } fun geterror(errorkeyfromtracker: string): string { val str = errors.getvalue(errorkeyfromtracker) return context.resources.getstring(str) } override fun onflushcompleted() { log.i(tag, "onflushcompleted()") coroutinescope.runcatching { trysendblocking(trackermessage.flushcompletedmessage) } } override fun onerror(trackererror: healthtracker.trackererror?) { log.i(tag, "onerror()") coroutinescope.runcatching { trysendblocking(trackermessage.trackererrormessage(geterror(trackererror.tostring()))) } } } heartratetracker = healthtrackingservice!!.gethealthtracker(trackingtype) setlistener(updatelistener) awaitclose { log.i(tag, "tracking flow awaitclose()") stoptracking() } } each tracking result is within a list in the datapoints argument of the ondatareceived() update listener. the sample application implements on-demand heart rate tracking, the update listener is invoked every second and each data point list contains 1 element. to extract a heart rate from data point: val hrvalue = datapoint.getvalue(valuekey.heartrateset.heart_rate) val hrstatus = datapoint.getvalue(valuekey.heartrateset.heart_rate_status) a status parameter is returned in addition to the heart rate data. if the heart rate reading was successful, its value is 1. each inter-beat interval data point consists of a list of values and the corresponding status for each value. since samsung privileged health sdk version 1.2.0, there can be up to 4 ibi values in a single data point, depending on the heart rate. if the ibi reading is valid, the value of the status parameter is 0. to extract only ibi data that is valid and whose value is not 0: private fun isibivalid(ibistatus: int, ibivalue: int): boolean { return ibistatus == 0 && ibivalue != 0 } fun getvalidibilist(datapoint: datapoint): arraylist<int> { val ibivalues = datapoint.getvalue(valuekey.heartrateset.ibi_list) val ibistatuses = datapoint.getvalue(valuekey.heartrateset.ibi_status_list) val validibilist = arraylist<int>() for ((i, ibistatus) in ibistatuses.withindex()) { if (isibivalid(ibistatus, ibivalues[i])) { validibilist.add(ibivalues[i]) } } send data to the mobile application the application uses the messageclient class of the wearable data layer api to send messages to the connected mobile device. messages are useful for remote procedure calls (rpc), one-way requests, or in request-or-response communication models. when a message is sent, if the sending and receiving devices are connected, the system queues the message for delivery and returns a successful result code. the successful result code does not necessarily mean that the message was delivered successfully, as the devices can be disconnected before the message is received. to advertise and discover devices on the same network with features that the watch can interact with, use the capabilityclient class of the wearable data layer api. each device on the network is represented as a node that supports various capabilities (features) that an application defines at build time or configures dynamically at runtime. your watch application can search for nodes with a specific capability and interact with it, such as sending messages. this can also work in the opposite direction, with the wearable application advertising the capabilities it supports. when the user taps the send button on the wearable application ui, the sendmessage() function from the mainviewmodel class is invoked, which triggers code in the sendmessageusecase class: override suspend fun sendmessage(message: string, node: node, messagepath: string): boolean { val nodeid = node.id var result = false nodeid.also { id -> messageclient .sendmessage( id, messagepath, message.tobytearray(charset = charset.defaultcharset()) ).apply { addonsuccesslistener { log.i(tag, "sendmessage onsuccesslistener") result = true } addonfailurelistener { log.i(tag, "sendmessage onfailurelistener") result = false } }.await() log.i(tag, "result: $result") return result } } to find a destination node for the message, retrieve all the available capabilities on the network: override suspend fun getcapabilitiesforreachablenodes(): map<node, set<string>> { log.i(tag, "getcapabilities()") val allcapabilities = capabilityclient.getallcapabilities(capabilityclient.filter_reachable).await() return allcapabilities.flatmap { (capability, capabilityinfo) -> capabilityinfo.nodes.map { it to capability } } .groupby( keyselector = { it.first }, valuetransform = { it.second } ) .mapvalues { it.value.toset() } } since the mobile module of the sample application advertises having the “wear” capability, to find an appropriate destination node, retrieve the list of connected nodes that support it: override suspend fun getnodesforcapability( capability: string, allcapabilities: map<node, set<string>> ): set<node> { return allcapabilities.filtervalues { capability in it }.keys } select the first node from the list, encode the message as a json string, and send the message to the node: suspend operator fun invoke(): boolean { val nodes = getcapablenodes() return if (nodes.isnotempty()) { val node = nodes.first() val message = encodemessage(trackingrepository.getvalidhrdata()) messagerepository.sendmessage(message, node, message_path) true } else { log.i(tag, "no compatible nodes found") false } } implementing the mobile application the mobile application ui consists of a list of the heart rate and inter-beat interval values received from the watch. the list is scrollable. mobile application ui receive and display data from the watch application to enable the mobile application to listen for data from the watch and launch when it receives data, define the datalistenerservice service in the mobile application’s androidmanifest.xml file, within the <application> element: <service android:name="com.samsung.health.mobile.data.datalistenerservice" android:exported="true"> <intent-filter> <action android:name="com.google.android.gms.wearable.data_changed" /> <action android:name="com.google.android.gms.wearable.message_received" /> <action android:name="com.google.android.gms.wearable.request_received" /> <action android:name="com.google.android.gms.wearable.capability_changed" /> <action android:name="com.google.android.gms.wearable.channel_event" /> <data android:host="*" android:pathprefix="/msg" android:scheme="wear" /> </intent-filter> </service> implement the datalistenerservice class in the application code to listen for and receive message data. the received json string data is passed as a parameter: private const val tag = "datalistenerservice" private const val message_path = "/msg" class datalistenerservice : wearablelistenerservice() { override fun onmessagereceived(messageevent: messageevent) { super.onmessagereceived(messageevent) val value = messageevent.data.decodetostring() log.i(tag, "onmessagereceived(): $value") when (messageevent.path) { message_path -> { log.i(tag, "service: message (/msg) received: $value") if (value != "") { startactivity( intent(this, mainactivity::class.java) .addflags(intent.flag_activity_new_task).putextra("message", value) ) } else { log.i(tag, "value is an empty string") } } } to decode the message data: fun decodemessage(message: string): list<trackeddata> { return json.decodefromstring(message) } to display the received data on the application screen: @composable fun mainscreen( results: list<trackeddata> ) { column( modifier = modifier .fillmaxsize() .background(color.black), verticalarrangement = arrangement.top, horizontalalignment = alignment.centerhorizontally ) { spacer( modifier .height(70.dp) .fillmaxwidth() .background(color.black) ) listview(results) } } running the applications to run the wearable and mobile applications: connect your galaxy watch and android mobile device (both devices must be paired with each other) to android studio on your computer. select wear from the modules list and the galaxy watch device from the devices list, then click run. the wearable application launches on the watch. connected devices select mobile from the modules list and the android mobile device from the devices list, then click run. the mobile application launches on the mobile device. wear the watch on your wrist and tap start. the watch begins tracking your heart rate. after some tracked values appear on the watch screen, to send the values to the mobile application, tap send. if the mobile application is not running, it is launched. the tracked heart data appears on the mobile application screen. to stop tracking, tap stop on the watch. conclusions the samsung privileged health sdk enables you to track health data, such as heart rate, from a user’s galaxy watch4 or higher smartwatch model. to display the tracked data on a larger screen, you can use the messageclient of the wearable data layer api to send the data to a companion application on the connected mobile device. to develop more advanced application features, you can also use the dataclient class to send data to devices not currently in range of the watch, delivering it only when the device is connected. resources heart rate data transfer code lab
Samsung Developers
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.