Filter
-
Content Type
-
Category
Mobile/Wearable
Visual Display
Digital Appliance
Platform
Recommendations
Filter
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
featured
bloganother year will soon be past and, like many of you, we’re looking forward to next year. we’ll be taking some time the next few weeks to be with our families, and will be back in 2022 with more blogs, podcasts, product announcements, and ways for you to succeed with galaxy store and samsung platforms. with the end-of-year holidays upon us, we’re stopping to reflect on what we did in 2021. even with covid making a disruption in everyone’s lives, we’re still here to help developers find answers and hopefully, also find success. here are some of our most memorable moments. 10. developer portal refresh brought a modern look and support for mobile we’ve been working for several years to bring samsung’s developer portal into a single web infrastructure. we moved content from multiple servers and cloud services into a cms that uses open standards and a responsive design for mobile devices. we pored through a decade of content to make sure it was still timely and accurate for your needs today. we integrated the developer forums to use the same samsung account login for both the developer portal and seller portal to give you a more seamless experience. in october of this year, we made a ux refresh to the site and the most amazing thing is how easy that process went. there were no late nights in the weeks prior to launch. we were able to test the new ux in a sandbox rigorously. then the deployment to production happened almost instantaneously. we spent less time worrying about our website and more time creating the content you need to do your work. we understand how important the samsung developer portal is to you and your work. that’s why we took the time to ensure a smooth transition as we made major infrastructure changes. 9. monthly updates keep developers up-to-date on new galaxy store features the galaxy store product management team began publishing monthly newsletters to enlighten developers of the latest features and improvements to seller portal. these updates also usually appear as blog posts in the first week or two of the month. some of the major announcements include: staged app rollouts (october) local currencies in settlement and financial reports (september) private beta testing (july) galaxy store developer api (april) look for more exciting improvements in 2022 as galaxy store continues to innovate. 8. unpacked events bring exciting new product announcements galaxy unpacked in january 2021 brought announcements of the galaxy buds pro, galaxy s21, and the new galaxy smarttag. the event highlighted samsung’s design concepts with one ui 3 and integrated experiences from partners like microsoft and google. the august galaxy unpacked event brought announcements of galaxy z fold3 and galaxy z flip3 phones. these devices have many new hardware and software features for developers to build upon. this blog post highlighted many of the ways that developers can implement features supporting flex mode and s pen remote, while ensuring that users have a seamless experience with app continuity. the most anticipated announcement of the august galaxy unpacked event was the unveiling of galaxy watch4, featuring wear os, powered by samsung. as with the tizen-powered galaxy watch devices, samsung released a new tool, galaxy watch studio converter, to help existing designers bring their watch faces to wear os. designers could also start a new watch face project from scratch with the newly-released watch face studio tool. 7. remote test lab updates allow developers to experience the latest hardware as new devices are announced, developers can use the remote test lab (rtl) to ensure that their apps work properly on the new version of one ui as well as different screen resolutions and pixel densities. in 2021, the rtl development team added support for foldables and galaxy s21 devices, allowing developers to ensure their apps work correctly before the devices are available to consumers. the rtl team also added support for android studio. in september, thousands of devices were added in data centers around the world to ensure that a compatible device is always available. as part of this release, rtl was re-engineered to work exclusively in the chrome browser, so that no external software is needed to test apps on all the latest devices. 6. samsung developer forums activity the samsung developer forums, based on the popular open-source discourse project, were introduced in january 2020, replacing an aging forum infrastructure that didn’t work well on mobile devices. by using the same samsung account authentication method as the samsung developers site, we’re able to provide a nearly-seamless experience across different hosts and platforms. since their introduction, we’ve seen large numbers of visitors stop by the forums with questions. community manager ron liechty has more than 25 years of experience in managing healthy communities—his knowledge and guidance keeps the forums a useful resource for developers. some of these visitors have become our best community members, providing valuable feedback to their peers as well as helping to moderate spam and malicious content. 5. supporting game developers in 2021 games are a noticeable part of the galaxy store experience and we work with many partners and internal teams to ensure that gamers have a great experience on galaxy devices. the galaxy gamedev team works closely with some of the top publishers and developers to improve performance of top titles on mobile. this team creates tools that provide great detail on the performance of the cpu and gpu during intense moments of gameplay. the gamedev team then documents their efforts in a series of best practices and blog posts to help developers everywhere. in addition to our internal team work, we frequently work with our partners at arm to deliver relevant content for game developers. this summer, we published and promoted a number of educational articles, webinars, and training series in cooperation with the arm developer team. best practices for mobile game developers and artists new vulkan extensions for mobile: maintenance extensions new vulkan extensions for mobile: legacy support extensions new game changing vulkan extensions for mobile: descriptor indexing new game changing vulkan extensions for mobile: buffer device address new game changing vulkan extensions for mobile: timeline semaphores mike barnes from the gamedev team, together with eric cloninger from the samsung developers team, presented at the virtual gdc2021 event in july. gdc is an important event for all of us at samsung and we hope to see you all there at the live event in march 2022. 4. new voices appeared on samsung developers podcast, season 2 shortly before the covid-19 pandemic changed our lives, tony morelan from samsung developers attended a podcasting event and came back to the office inspired to start a podcast. he lined up guests from internal teams and important partners. everyone had a great time participating and it gave us a way to continue delivering quality content to developers. as 2020 turned to 2021, we continued bringing interesting guests from across the mobile design and development ecosystem. we used the podcast to talk about the upcoming virtual samsung developer conference and chat with the people that made the event a success. here are some of the highlights from season 2 of the samsung developers podcast: drazen stojcic, urarity – watch faces, design tan nguyen, butterfly-effected gmbh – galaxy themes, marketing, licensing the samsung internet advocacy team – web standards, privacy, foldable devices we’re still hoping for a return to days where we can travel and meet in person, but until that time comes, please join us in listening to these industry veterans and top developers on the samsung developers podcast. season 3 begins in early 2022. 3. blog series instructs readers on design and successful marketing without live events the past two years, we have searched for new ways to continue delivering timely and helpful advice to mobile app designers and developers. as mentioned previously, we worked with arm this year to bring great technical content front and center. we also worked with our network of top designers, developers, and thought leaders on concepts that will help you succeed on galaxy store and in creating better experiences for your users: better for all – in this blog series, we talked with leading designers and experts to help understand the increasingly important concepts behind the diversity, equality, and inclusion movement. this series discussed aspects of language used in apps, themes, and watch designs. it also highlights important guidelines to ensure apps and web sites are accessible to users with sight, mobility, and hearing impairments. better for all: mobile accessibility better for all: inclusive policies with daniel appelquist better for all: equal accessibility better for all: bringing diversity to design with eglantina hasaj and manpreet kaur better for all: diversity in design better for all: developing and designing for diversity refresh for success – it’s not enough to simply submit a title to a digital marketplace and assume success will follow and continue without extra effort. in this series, top galaxy store designers and developers talk about how they maintain their product lines to ensure a steady flow of revenue and new customers. refresh for success: maintain quality themes design with olga gabay from zeru studio refresh for success: improve your process to keep designs fresh with tan nguyen from butterfly-effected, gmbh refresh for success: improve your process and de-clutter your galaxy store with drazen stojcic from urarity prime time design – finding success in designing new products is an intensely unique and personal process. the prime time design series includes interviews with some of the most unique people creating for galaxy store. read how these talented people inspire themselves and how they convert that inspiration into action. prime time design: unpacking the creative process with ramon campos from friss in motion prime time design: unpacking the creative process with pedro machado from health face prime time design: unpacking the creative process with john shih from x9 studio strategies for success – tony morelan was a successful watch face designer before coming to work with the samsung developers team. we’re grateful for his knowledge of design as well as how to turn designs into revenue. in this four-part series, tony points out steps to creating successful galaxy store product submissions. strategies for success: selling your apps strategies for success: understanding consumer trends strategies for success: building your fan base strategies for success: making your brand successful 2. best of galaxy store awards highlight successful developers the galaxy store app on your mobile device is more than just an app. behind the scenes, there is a team of developers, product managers, business leaders, and security experts devoted to ensuring the best possible online experience for consumers in 180 countries. because of their dedication, developers and designers have a great platform for monetizing their work. each year, the samsung developers team works with the galaxy store operations and business development teams to determine the best games, apps, and themes based on revenue, downloads, and impact to consumers. the result is the best of galaxy store awards. in 2018 and 2019, the best of galaxy store awards were presented live, on stage, at the samsung developer conference (sdc). without a live event in 2020 or 2021, the samsung developers team decided to continue the tradition of highlighting and awarding our top galaxy store products. even without an in-person event, we used a live premiere on youtube to have a single moment in time to celebrate with the winners. tony morelan emceed the event, but he had a lot of help from ron liechty, jeanne hsu, susie perez, and shelly wu. we thank them for their hard work. we hope you’ll enjoy watching! look for the “best of galaxy store” sash on apps, games, themes, and watch faces in galaxy store to know that you’re getting a truly unique experience. 1. discovering new opportunities at sdc21 each year, the samsung developer conference is the culmination of an incredible amount of planning and work by hundreds of people. even though the event was virtual in 2021, there was still a huge volume of work. instead of preparing for a live audience, our teams practiced in front of a galaxy phone on a tripod (really). instead of building booths and planning meals, we built a website and social media campaigns to reach a larger audience. eric cloninger and tony morelan kicked off the promotion for sdc21 with a podcast featuring a previous sdc speaker, chris shomo. before the conference, visitors were invited to create whimsical caricatures of themselves using the mysdcstack mini-site and submit their designs to social media. by participating in the event website, watching sessions, and trying the code labs, visitors would earn points toward a prize drawing after sdc. relive the experience of sdc21 by watching the keynote or any of the highlight sessions and technical talks by viewing this playlist wrapping up when sdc is finished, our team takes a collective deep breath, happy to be done. it is a satisfying experience to pull off a big industry event. we don’t know yet how we’ll handle live events, but we remain optimistic that some will occur. we are making plans and we hope we’ll be able to see you, somewhere, in 2022. 🤞 take care. stay warm (or cool). best wishes to you all and happy new year!
Learn Code Lab
codelabmatter build a matter iot app with smartthings home api objective learn how to create an iot app to onboard, control, remove, and share matter devices using smartthings home apis notesmartthings home apis are distributed only to authorized users if you want permission to use the apis, contact st matter@samsung com 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 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 matter virtual device app installed mobile device with developer mode and usb debugging enabled matter-enabled smartthings station onboarded with samsung account used for smartthings app tipyou can create a virtual device as a third-party iot device sample code noteyou can request permission to access the sample project file for this code lab by sending an email to st matter@samsung com 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 commission the device you can onboard a matter-compatible device to the iot app by calling the commissiondevice api, which can lay the groundwork to control, remove, and share the device go to app > java > com samsung android matter home sample > feature > main in the mainviewmodel kt file, call the commissiondevice api to launch the onboarding activity and join the device to the smarththings fabric // ================================================================================= // codelab // step 1 create an instance of matter commissioning client // step 2 call the commissiondevice api to launch the onboarding activity in home service // step 3 set _intentsender value from return value of commissiondevice api // todo 1 device commission and join a device to smartthings fabric // todo 1 uncomment the following code blocks // --------------------------------------------------------------------------------- //val commissioningclient = matter getcommissioningclient //val intentsender = commissioningclient commissiondevice context //_intentsender value = intentsender // ================================================================================= control the device capabilities are core to the smartthings architecture they abstract specific devices into their underlying functions, which allows the retrieval of the state of a device component or control of the device function each device has its own appropriate capabilities therefore, each device has a different control api, and the more functions it supports, the more apis it has to use in this step, select a device type that you want to onboard and control using necessary home apis the level of modification complexity is assigned per each device contact sensorlevel 1 3 mins file path app > java > com samsung android matter home sample > feature > device file name contactsensorviewmodel kt // ================================================================================= // codelab level 1 // step 1 get contactsensor capability from device instance // step 2 get stream openclose value from contactsensor capability // step 3 set _openclose value for ui updating // todo 1 uncomment the following code blocks // --------------------------------------------------------------------------------- //device readcapability contactsensor ? openclose? collect { openclose -> // _openclose value = openclose //} // ================================================================================= // ================================================================================= // codelab level 1 // step 1 get battery capability from device instance // step 2 get stream battery value from battery capability // step 3 set _batterystatus value for ui updating // todo 2 uncomment the following code blocks // --------------------------------------------------------------------------------- //device readcapability battery ? battery? collect { battery -> // _batterystatus value = battery //} // ================================================================================= motion sensorlevel 1 3 mins file path app > java > com samsung android matter home sample > feature > device file name motionsensorviewmodel kt // ================================================================================= // codelab level 1 // step 1 get motionsensor capability from device instance // step 2 get stream occupied value from motionsensor capability // step 3 set _motionoccupied value for ui updating // todo 1 uncomment the following code blocks // --------------------------------------------------------------------------------- //device readcapability motionsensor ? occupied? collect { motionoccupied -> // _motionoccupied value = motionoccupied // timber d "occupied= $motionoccupied" //} // ================================================================================= // ================================================================================= // codelab level 1 // step 1 get battery capability from device instance // step 2 get stream battery value from battery capability // step 3 set _batterystatus value for ui updating // todo 2 uncomment the following code blocks // --------------------------------------------------------------------------------- //device readcapability battery ? battery? collect { battery -> // _batterystatus value = battery // timber d "battery= $battery" //} // ================================================================================= on-off switchlevel 2 4 mins file path app > java > com samsung android matter home sample > feature > device file name switchviewmodel kt // ================================================================================= // codelab level 2 // step 1 get switch capability from device instance // step 2 get stream onoff value from switch capability // step 3 set _onoff value for ui updating // todo 1 uncomment the following code blocks // --------------------------------------------------------------------------------- //device readcapability switch ? onoff? collect { onoff -> // _onoff value = onoff //} // ================================================================================= // ================================================================================= // codelab level 2 // step 1 get switch capability from device instance // step 2 control the device using the apis that supported by switch capability // toggle switch state based on onoff value // onoff == true call switch off // onoff == false call switch on // todo 2 uncomment the following code blocks // --------------------------------------------------------------------------------- //device readcapability switch ? let { switch -> // if onoff == true { // switch off // } else { // switch on // } //} // ================================================================================= smart locklevel 3 8 mins file path app > java > com samsung android matter home sample > feature > device file name smartlockviewmodel kt // ================================================================================= // codelab level 3 // step 1 get lock capability from device instance // step 2 get stream lockunlock value from lock capability // step 3 set _lockstatus value for ui updating // --------------------------------------------------------------------------------- // todo 1 copy code below device readcapability lock ? lockunlock? collect { lockunlock -> _lockstatus value = lockunlock } // ================================================================================= // ================================================================================= // codelab level 3 // step 1 get tamperalert capability from device instance // step 2 get stream tamperalert value from tamperalert capability // step 3 set _tamperstatus value for ui updating // --------------------------------------------------------------------------------- // todo 2 copy code below device readcapability tamperalert ? tamperalert? collect { tamperalert -> _tamperstatus value = tamperalert } // ================================================================================= // ================================================================================= // codelab level 3 // step 1 get battery capability from device instance // step 2 get stream battery value from battery capability // step 3 set _batterystatus value for ui updating // --------------------------------------------------------------------------------- // todo 3 copy code below device readcapability battery ? battery? collect { battery -> _batterystatus value = battery } // ================================================================================= // ================================================================================= // codelab level 3 // step 1 get lock capability from device instance // step 2 control the device using the apis that supported by lock capability // toggle lock state based on lockunlock value // lockunlock == true call lock // lockunlock == false call unlock // --------------------------------------------------------------------------------- // todo 4 copy code below device readcapability lock ? let { lock -> if lockunlock == true { lock lock } else { lock unlock } } // ================================================================================= blindslevel 3 8 mins file path app > java > com samsung android matter home sample > feature > device file name blindviewmodel kt // ================================================================================= // codelab level 3 // step 1 get windowshade capability from device instance // step 2 get stream windowshademode value from windowshade capability // step 3 set _windowshademode value for ui updating // --------------------------------------------------------------------------------- // todo 1 copy code below device readcapability windowshade ? windowshademode? collect { windowshademode -> timber d "windowshademode $windowshademode" _windowshademode value = windowshademode } // ================================================================================= // ================================================================================= // codelab level 3 // step 1 get windowshadelevel capability from device instance // step 2 get stream shadelevel value from windowshadelevel capability // step 3 set _shadelevel value for ui updating // --------------------------------------------------------------------------------- // todo 2 copy code below device readcapability windowshadelevel ? shadelevel? collect { shadelevel -> timber d "shadelevel $shadelevel" _shadelevel value = shadelevel } // ================================================================================= // ================================================================================= // codelab level 3 // step 1 get battery capability from device instance // step 2 get stream battery value from battery capability // step 3 set _batterystatus value for ui updating // --------------------------------------------------------------------------------- // todo 3 copy code below device readcapability battery ? battery? collect { battery -> _batterystatus value = battery } // ================================================================================= // ================================================================================= // codelab level 3 // step 1 get windowshade capability from device instance // step 2 control the device using the apis that supported by windowshade capability // send windowshade open/close/pause command based on controlcommand value // "open" call windowshade open // "close" call windowshade close // "pause" call windowshade pause // --------------------------------------------------------------------------------- // todo 4 copy code below device readcapability windowshade ? let { windowshade -> when controlcommand { "open" -> windowshade open "close" -> windowshade close "pause" -> windowshade pause } } // ================================================================================= extended color lightlevel 4 10 mins file path app > java > com samsung android matter home sample > feature > device file name lightviewmodel kt // ================================================================================= // codelab level 4 // step 1 get switch capability from device instance // step 2 get stream onoff value from switch capability // step 3 set _onoff value for ui updating // --------------------------------------------------------------------------------- // todo 1 copy code below device readcapability switch ? onoff? collect { onoff -> _onoff value = onoff } // ================================================================================= // ================================================================================= // codelab level 4 // step 1 get switchlevel capability from device instance // step 2 get stream level value from switchlevel capability // step 3 set _level value for ui updating // --------------------------------------------------------------------------------- // todo 2 copy code below device readcapability switchlevel ? level? collect { level -> _level value = level } // ================================================================================= // ================================================================================= // codelab level 4 // step 1 get switch capability from device instance // step 2 control the device using the apis that supported by switch capability // toggle switch state based on onoff value // onoff == true call switch off // onoff == false call switch on // --------------------------------------------------------------------------------- // todo 3 copy code below device readcapability switch ? let { switch -> if onoff == true { switch off } else { switch on } } // ================================================================================= // ================================================================================= // codelab level 4 // step 1 get switchlevel capability from device instance // step 2 control the device using the apis that supported by switchlevel capability // call switchlevel setlevel with percentage value // --------------------------------------------------------------------------------- // todo 4 copy code below timber d "target position = $percentage" device readcapability switchlevel ? setlevel percentage // ================================================================================= // ================================================================================= // codelab level 4 // step 1 get colorcontrol capability from device instance // step 2 control the device using the apis that supported by colorcontrol capability // call colorcontrol setcolor with hue,saturation value // --------------------------------------------------------------------------------- // todo 5 copy code below timber d "hue $hue,saturation $saturation" device readcapability colorcontrol ? setcolor hue todouble , saturation todouble // ================================================================================= // ================================================================================= // codelab level 4 // step 1 get colortemperature capability from device instance // step 2 control the device using the apis that supported by colortemperature capability // call colortemperature setcolortemperature with temperature // --------------------------------------------------------------------------------- // todo 6 copy code below device readcapability colortemperature ? setcolortemperature temperature // ================================================================================= video playerlevel 4 10 mins file path app > java > com samsung android matter home sample > feature > device file name televisionviewmodel kt // ================================================================================= // codelab level 4 // step 1 get switch capability from device instance // step 2 get stream onoff value from switch capability // step 3 set _onoff value for ui updating // --------------------------------------------------------------------------------- // todo 1 copy code below device readcapability switch ? onoff? collect { onoff -> _onoff value = onoff } // ================================================================================= // ================================================================================= // codelab level 4 // step 1 get mediaplayback capability from device instance // step 2 get stream mediaplaybackstate value from mediaplayback capability // step 3 set _mediaplaybackstate value for ui updating // --------------------------------------------------------------------------------- // todo 2 copy code below device readcapability mediaplayback ? mediaplaybackstate? collect { mediaplaybackstate -> _mediaplaybackstate value = mediaplaybackstate } // ================================================================================= // ================================================================================= // codelab level 4 // step 1 get switch capability from device instance // step 2 control the device using the apis that supported by switch capability // toggle switch state based on onoff value // onoff == true call switch off // onoff == false call switch on // --------------------------------------------------------------------------------- // todo 3 copy code below device readcapability switch ? let { switch -> if onoff == true { switch off } else { switch on } } // ================================================================================= // ================================================================================= // codelab level 4 // step 1 get mediaplayback capability from device instance // step 2 control the device using the apis that supported by mediaplayback capability // send mediaplayback play/pause/stop/rewind/fastforward command based on controlcommand value // "play" call mediaplayback play and setplaybackstatus with playbackstatus playing // "pause" call mediaplayback pause and setplaybackstatus with playbackstatus paused // "stop" call mediaplayback stop and setplaybackstatus with playbackstatus stopped // "rewind" call mediaplayback rewind and setplaybackstatus with playbackstatus rewinding // "fastforward" call mediaplayback fastforward and setplaybackstatus with playbackstatus fastforwarding // --------------------------------------------------------------------------------- // todo 4 copy code below device readcapability mediaplayback ? let { mediaplayback -> when controlcommand { "play" -> { mediaplayback play mediaplayback setplaybackstatus playbackstatus playing } "pause" -> { mediaplayback pause mediaplayback setplaybackstatus playbackstatus paused } "stop" -> { mediaplayback stop mediaplayback setplaybackstatus playbackstatus stopped } "rewind" -> { mediaplayback rewind mediaplayback setplaybackstatus playbackstatus rewinding } "fastforward" -> { mediaplayback fastforward mediaplayback setplaybackstatus playbackstatus fastforwarding } } } // ================================================================================= // ================================================================================= // codelab level 4 // step 1 get mediatrackcontrol capability from device instance // step 2 control the device using the apis that supported by mediatrackcontrol capability // send mediatrack nexttrack/previoustrack command based on controlcommand value // "nexttrack" call mediatrack nexttrack // "previoustrack" call mediatrack previoustrack // --------------------------------------------------------------------------------- // todo 5 copy code below device readcapability mediatrackcontrol ? let { mediatrack -> when controlcommand { "nexttrack" -> mediatrack nexttrack "previoustrack" -> mediatrack previoustrack } } // ================================================================================= // ================================================================================= // codelab level 4 // step 1 get keypadinput capability from device instance // step 2 control the device using the apis that supported by keypadinput capability // call keypadinput sendkey with key value // --------------------------------------------------------------------------------- // todo 6 copy code below device readcapability keypadinput ? sendkey key // ================================================================================= thermostatlevel 5 13 mins file path app > java > com samsung android matter home sample > feature > device file name thermostatviewmodel kt // ================================================================================= // codelab level 5 // step 1 get thermostatmode capability from device instance // step 2 get stream thermostatmode value from thermostatmode capability // step 3 set _systemmode value for ui updating // --------------------------------------------------------------------------------- // todo 1 copy code below device readcapability thermostatmode ? thermostatmode? collect { thermostatmode -> timber d "viewmodel thermostatmode $thermostatmode" _systemmode value = thermostatmode } // ================================================================================= // ================================================================================= // codelab level 5 // step 1 get thermostatfanmode capability from device instance // step 2 get stream thermostatfanmode value from thermostatfanmode capability // step 3 set _fanmode value for ui updating // --------------------------------------------------------------------------------- // todo 2 copy code below device readcapability thermostatfanmode ? thermostatfanmode? collect { fanmode -> _fanmode value = fanmode } // ================================================================================= // ================================================================================= // codelab level 5 // step 1 get temperaturemeasurement capability from device instance // step 2 get stream temperature value from temperaturemeasurement capability // step 3 set _temperature value for ui updating // --------------------------------------------------------------------------------- // todo 3 copy code below device readcapability temperaturemeasurement ? temperature? collect { temperature -> _temperature value = temperature } // ================================================================================= // ================================================================================= // codelab level 5 // step 1 get thermostatcoolingsetpointbattery capability from device instance // step 2 get stream coolingsetpoint value from thermostatcoolingsetpoint capability // step 3 set _occupiedcoolingsetpoint value for ui updating // --------------------------------------------------------------------------------- // todo 4 copy code below device readcapability thermostatcoolingsetpoint ? coolingsetpoint? collect { coolingsetpoint -> _occupiedcoolingsetpoint value = coolingsetpoint } // ================================================================================= // ================================================================================= // codelab level 5 // step 1 get thermostatheatingsetpoint capability from device instance // step 2 get stream heatingsetpoint value from thermostatheatingsetpoint capability // step 3 set _occupiedheatingsetpoint value for ui updating // --------------------------------------------------------------------------------- // todo 5 copy code below device readcapability thermostatheatingsetpoint ? heatingsetpoint? collect { heatingsetpoint -> _occupiedheatingsetpoint value = heatingsetpoint } // ================================================================================= // ================================================================================= // codelab level 5 // step 1 get relativehumiditymeasurement capability from device instance // step 2 get stream humidity value from relativehumiditymeasurement capability // step 3 set _humidity value for ui updating // --------------------------------------------------------------------------------- // todo 6 copy code below device readcapability relativehumiditymeasurement ? humidity? collect { humidity -> _humidity value = humidity } // ================================================================================= // ================================================================================= // codelab level 5 // step 1 get battery capability from device instance // step 2 get stream battery value from battery capability // step 3 set _batterystatus value for ui updating // --------------------------------------------------------------------------------- // todo 7 copy code below device readcapability battery ? battery? collect { battery -> _batterystatus value = battery } // ================================================================================= // ================================================================================= // codelab level 5 // step 1 get thermostatmode capability from device instance // step 2 control the device using the apis that supported by thermostatmode capability // change thermostatmode state based on systemmode value // thermostatsystemmode off call thermostatmode off // thermostatsystemmode cool call thermostatmode cool // thermostatsystemmode heat call thermostatmode heat // thermostatsystemmode auto call thermostatmode auto // --------------------------------------------------------------------------------- // todo 8 copy code below device readcapability thermostatmode ? let { thermostatmode -> when systemmode { thermostatsystemmode off -> thermostatmode off thermostatsystemmode cool -> thermostatmode cool thermostatsystemmode heat -> thermostatmode heat thermostatsystemmode auto -> thermostatmode auto } } // ================================================================================= // ================================================================================= // step 1 get thermostatfanmode capability from device instance // step 2 control the device using the apis that supported by thermostatfanmode capability // change thermostatfanmode state based on fanmode value // thermostatfanmodeenum auto call thermostatfanmode fanauto // thermostatfanmodeenum circulate call thermostatfanmode fancirculate // thermostatfanmodeenum followschedule call thermostatfanmode setthermostatfanmode with followschedule // thermostatfanmodeenum on call thermostatfanmode fanon // --------------------------------------------------------------------------------- // todo 9 copy code below device readcapability thermostatfanmode ? let { thermostatfanmode -> when fanmode { thermostatfanmodeenum auto -> thermostatfanmode fanauto thermostatfanmodeenum circulate -> thermostatfanmode fancirculate thermostatfanmodeenum followschedule -> thermostatfanmode setthermostatfanmode "followschedule" thermostatfanmodeenum on -> thermostatfanmode fanon } } // ================================================================================= // ================================================================================= // codelab level 5 // step 1 get thermostatheatingsetpoint capability value from device instance // step 2 increase _occupiedheatingsetpoint value that have current heating value // step 3 if new increased value is under value_max 104 , // call setheatingsetpoint of thermostatheatingsetpoint capability with new increased value // --------------------------------------------------------------------------------- // todo 10 copy code below device readcapability thermostatheatingsetpoint ? let { heatingsetpoint -> val nextvalue = _occupiedheatingsetpoint value!! + 1 if nextvalue < value_max { heatingsetpoint setheatingsetpoint nextvalue } } // ================================================================================= // ================================================================================= // codelab level 5 // step 1 get thermostatheatingsetpoint capability value from device instance // step 2 decrease _occupiedheatingsetpoint value that have current heating value // step 3 if new decreased value is over value_min 32 , // call setheatingsetpoint of thermostatheatingsetpoint capability with new decreased value // --------------------------------------------------------------------------------- // todo 11 copy code below device readcapability thermostatheatingsetpoint ? let { heatingsetpoint -> val nextvalue = _occupiedheatingsetpoint value!! - 1 if nextvalue > value_min { heatingsetpoint setheatingsetpoint nextvalue } } // ================================================================================= // ================================================================================= // codelab level 5 // step 1 get thermostatcoolingsetpoint capability value from device instance // step 2 increase _occupiedcoolingsetpoint value that have current cooling value // step 3 if new increased value is under value_max 104 , // call setcoolingsetpoint of thermostatcoolingsetpoint capability with new increased value // --------------------------------------------------------------------------------- // todo 12 copy code below device readcapability thermostatcoolingsetpoint ? let { coolingsetpoint -> val nextvalue = _occupiedcoolingsetpoint value!! + 1 if nextvalue < value_max { coolingsetpoint setcoolingsetpoint nextvalue } } // ================================================================================= // ================================================================================= // codelab level 5 // step 1 get thermostatcoolingsetpoint capability value from device instance // step 2 decrease _occupiedcoolingsetpoint value that have current cooling value // step 3 if new decreased value is over value_min 32 , // call setcoolingsetpoint of thermostatcoolingsetpoint capability with new decreased value // --------------------------------------------------------------------------------- // todo 13 copy code below device readcapability thermostatcoolingsetpoint ? let { coolingsetpoint -> val nextvalue = _occupiedcoolingsetpoint value!! - 1 if nextvalue > value_min { coolingsetpoint setcoolingsetpoint nextvalue } } // ================================================================================= noteyou can find related files in android studio by going to edit menu> find > find in files and entering the keyword "codelab" remove the device using removedevice api, you can remove the device from your iot app and the smartthings fabric go to app > java > com samsung android matter home sample > feature > device > base in the baseviewmodel kt file, call the removedevice api to launch the removedevice activity // ================================================================================= // [codelab] device remove from smartthings fabric // step 1 create an instance of matter commissioning client // step 2 call the removedevice api to launch the removedevice activity in home service // step 3 set _intentsender value from return value of removedevice api // todo 1 uncomment the following code blocks // --------------------------------------------------------------------------------- //val commissioningclient = matter getcommissioningclient //val intentsender = commissioningclient removedevice // context, // commissioningclient removedevicerequest deviceid // //_intentsenderforremovedevice value = intentsender // ================================================================================= share the device matter devices can be shared with other matter-compatible iot platforms, such as google home, using home apis without resetting the device while connected to smartthings to perform this operation, it is necessary to enter the commissioning mode without resetting the device in the baseviewmodel kt file, call the sharedevice api to launch the sharedevice activity // ================================================================================= // [codelab] device share to other platforms // step 1 create an instance of matter commissioning client // step 2 call the sharedevice api to launch the sharedevice activity in home service // step 3 set _intentsender value from return value of sharedevice api // todo 1 uncomment the following code blocks // --------------------------------------------------------------------------------- //val commissioningclient = matter getcommissioningclient //val intentsender = commissioningclient sharedevice // context, // commissioningclient sharedevicerequest deviceid // //_intentsenderforsharedevice value = intentsender // ================================================================================= build and run the iot app run the sample app to build and run your iot app, follow these steps using a usb cable, connect your mobile device select the sample iot app from the run configurations menu in the android studio then, select the connected device in the target device menu click run onboard to onboard the virtual device go to the matter virtual device app then, select and set up the virtual device type you want to control click save click start to show the qr code for onboarding go to the sample iot app and click the + button then, onboard the virtual device by scanning its qr code control by sample iot app in the sample iot app, control the virtual device by using its various functions such as on and off for switch you're done! congratulations! you have successfully achieved the goal of this code lab topic now, you can create a matter-compatible iot application with smartthings home apis by yourself! learn more by going to smartthings matter libraries
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.