Filter
-
Content Type
-
Category
Mobile/Wearable
Visual Display
Digital Appliance
Platform
Recommendations
Filter
Learn Code Lab
codelabverify your id with samsung wallet objective learn how to verify a user's identity with the id information registered in their samsung wallet app partnership request to create, manage, and monitor performance of wallet cards with the samsung wallet partners site, you must become an official samsung partner once done, you can fully utilize this code lab you can learn more by visiting samsung wallet partner onboarding process, here in samsung developers notein accordance with the applicable samsung wallet partners agreements, this code lab covers the setup and use of the verify with samsung wallet service for purposes of integrating samsung wallet with partner sites and apps the use cases and corresponding code samples included are representative examples only and should not be considered as either recommended or required overview verify with samsung wallet enables users to utilize the digital id added to their wallets to simplify online transactions that require an identity verification a mobile device with samsung wallet installed is required to verify the user’s identity through this feature this feature uses the relying party card type to verify a user's identity using the id information stored in samsung wallet this feature supports app-to-app app2app and web-to-app web2app integration models the web2app integration supports the partner's mobile web application to request a verification to the samsung wallet app the app2app integration supports the partner’s mobile application to request a verification to the samsung wallet app when the partner site requests the user to verify their identity, the verify with samsung wallet button is displayed the user is redirected to the samsung wallet app where they verify their identity via pin or biometrics once verified, the user's identity information is sent to the partner and the transaction will proceed noteas of 2024, this feature is only available in the united states and can be used by the state government with mobile driver's license mdl support for more information, visit https //developer samsung com/dashboard/support for detailed description, see verify with samsung wallet set up your environment you will need the following access to samsung wallet partners site samsung galaxy device that supports samsung wallet app samsung wallet app latest version android studio latest version recommended java se development kit jdk 11 or later supported mobile driver's license be added to samsung wallet app internet browser, such as google chrome openssl intellij idea or any java ide optional sample code here is a sample code for you to start coding in this code lab download it and start your learning experience! verify with wallet sample code for app2app integration 802 3 kb start the onboarding process partners can manage wallet cards and monitor performance with the samsung wallet partners site to join as partner generate a private key and certificate signing request csr using the openssl command you can follow the instructions in security factors notea private key enables encryption and is the most important component of certificates while csr, which is a necessary factor to obtain a signed certificate, includes the public key and additional information like organization and country proceed to register in the samsung wallet partners site using your samsung account follow the samsung wallet partner onboarding process upload the generated csr for data encryption in encryption setting management section after registration, you will receive a welcome email noteupon receiving the certificates via email, be sure to keep the information safe from exposure and only use them for the following purposes signed certificate used along with the private key to sign data samsung certificate used to encrypt card data and validate authentication tokens in server api headers create a relying party wallet card follow the steps below to create a wallet card in samsung wallet partners site go to wallet cards > manage wallet card and click add wallet card in wallet card template field, choose [wallet] relying party as wallet card type and relyingparty > others as sub type select the design type and click done in wallet card custom setting, click change, and choose drivers as authentication issuer you can also select specific mdls such as below notethe authentication issuer is a unique property of the relying party card type the identity provider of the authentication issuer is supported depending on the service location set for example, if the service location is in the united states, the authentication issuer field only supports any identity provider in the united states region in main headquarters location, select united states once finished, select save to view all registered information launch wallet cards you can launch and request activation of the cards by clicking the launch button upon agreeing to proceed, the launch button text changes to launched and the card status becomes verifying create a verify with samsung wallet button app2app for the app2app integration, you need to setup the button inside the mobile application in android studio, click open locate the downloaded android project rpclient_codelab from the directory and click ok go to app > kotlin+java > com samsung android sample rpclient > presentation > partners and, in the partnersrequestfragment kt file, add the verify with samsung wallet button inside the oncreateview function glide with this load partner getverifybuttonimage into binding verifybutton set up a click listener for the verifybutton binding verifybutton setonclicklistener { /// add the requestdata variable to prepare the request fields /// add the applink variables to request the card information /// call the applink method to request verification } inside the listener, add the requestdata variable to prepare the request fields for verification val requestdata = demodata requestdata add the applink variables to request the card information val applink = rpclientapis buildapplink partnerid = partner getpartnerid , cardid = partner getcardid , payload = partner buildapp2apppayload , samsungpublickey = partner getsamsungpublickey , partnerpublickey = partner getpartnerpublickey , partnerprivatekey = partner getpartnerprivatekey , isstagingserver = true the data being requested are as follows partnerid = gets the partner id from the identification card used cardid = gets the card id from the identification card used payload = builds the app2app payload samsungpublickey = gets the samsung public key partnerpublickey = gets the partner's public key partnerprivatekey = gets the partner's private key isstagingserver = checks if the application runs on a staging environment noterequested data such as partnerid, public keys, and private keys are generated during the onboarding process, while cardid is generated when you create a wallet card however, in this code lab, these data is already predefined and included in the sample mobile app call the applink method to request verification this method creates a channel between the test app and samsung wallet app to create the request and response data for the verification process applink? let { log i tag, applink rpclientapis request "com samsung android spay", uuid randomuuid tostring , applink, object rpclientapis onresponselistener { override fun ongetmdocrequestdata deviceengagementbytes bytearray bytearray? { log i tag, "deviceengagementbytes=${deviceengagementbytes tohex }" val keypair = securerepository generateeckeypair log i tag, "requestdata=$requestdata" val encryptedsessionestablishmentbytes = securerepository buildsessionestablishment requestdata, deviceengagementbytes, keypair log i tag, "encryptedsessionestablishmentbytes=${encryptedsessionestablishmentbytes? tohex }" return encryptedsessionestablishmentbytes } override fun onmdocresponse encryptedresponsebytes bytearray { log i tag, "encryptedresponsebytes=${encryptedresponsebytes tohex }" try { val plainresponse = securerepository decryptmdocresponse encryptedresponsebytes log i tag, "plainresponse=${plainresponse? toprettyjson }" val responsedata = plainresponse? toprettyjson onresponse postvalue responsedata } catch e exception { e printstacktrace } } override fun onmdocresponsefailed exception exception { log i tag, "onmdocresponsefailed ${exception} " onerror postvalue exception } } } run and test the application app2app go to build > build app bundle s / apk s > build apk s to build the application install the apk file to your mobile device and test the sample app as follows open the sample app and choose sdc code lab press the verify with samsung wallet button once you are redirected to the samsung wallet app, press the verify button the samsung wallet app shows a checkmark to indicate that the identity has already been verified while the sample app displays a verification success screen test the verify with samsung wallet button web2app for the web2app integration, you can use the test tool to test the verify with samsung wallet button open a web browser on your computer or galaxy mobile device and go to the following link partner walletsvc samsung com/addtowallettest go to verify with wallet tab and click choose key file to upload your private key in the select card dropdown menu, select the card you created to display its details navigate to the form tab and modify the data as desired you can change the logo image or provider name press the verify with samsung wallet button once you are redirected to samsung wallet, press the verify button the samsung wallet app shows a checkmark to indicate that the identity has already been verified go back to the test tool, open the mdoc tab, and click the check result button it displays a result success popup when the verification process is successful tokenize card data and implement the verify with wallet button to your service optional notethis step is optional, but if you want to learn how to integrate the verify with wallet button into your services like an android app, web app, or email, you can follow these steps the samsung wallet partners site provides generated verify with samsung wallet scripts for each wallet card you create you can simply copy and paste these scripts into your partner apps web and android or include them in emails/mms messages to implement the verify with wallet button, follow these steps go to the [verify with wallet script guide] section of the card you created click show to view the available scripts and then copy the appropriate script for your service develop a program that can generate tokenized card data cdata the cdata represents the actual content of the wallet card and comes in different formats depending on the card type you can check the cdata generation sample code for reference the cdata is derived from the card data, which is in json format for testing purposes, you can utilize the generated json from the test tool follow the implementing button guide to determine where to incorporate the generated cdata and gain further insights into this process you are redirected back to your app and your identity is verified you're done! congratulations! you have successfully accomplished the topic of this code lab now, you are ready to verify your id with the verify with samsung wallet button into your application on your own! if you're having trouble, you may download this file verify with wallet complete code for app2app integration 802 5 kb to learn more about samsung wallet, visit developer samsung com/wallet
Learn Code Lab
codelabintegrate samsung pay web checkout with merchant sites objective learn how to integrate the samsung pay payment system into your merchant sites using the samsung pay web checkout sdk partnership request to use the samsung pay web checkout sdk, you must become an official samsung pay partner once done, you can fully utilize this code lab you can learn more about the partnership process by visiting the samsung pay page here in samsung developers notein accordance with the applicable samsung pay partners agreements, this code lab covers the setup and use of the samsung pay web checkout sdk for purposes of integrating samsung pay with merchant sites the use cases and corresponding code samples included are representative examples only and should not be considered as either recommended or required overview the samsung pay web checkout service enables users to pay for purchases on your website with payment cards saved in the samsung wallet app on their mobile device it supports browser-based payments on both computers and mobile devices a mobile device with samsung wallet installed is required to make purchases through samsung pay web checkout when the user chooses to pay with samsung pay, they must provide their samsung account id email id or scan the qr code on the screen with their mobile device the user then authorizes the purchase within the samsung wallet application, which generates the payment credential on the device and transmits it to your website through the web checkout for more information, see samsung pay web checkout set up your environment you will need the following access to samsung pay developers site samsung wallet test app from samsung pay developers site samsung galaxy device that supports samsung wallet app internet browser, such as google chrome codesandbox account notein this code lab, you can use the samsung wallet test app to try the functionality of the samsung pay web checkout service in a staging environment you can use the official samsung wallet app from the galaxy store once your service is in the production environment start your project and register your service in your browser, open the link below to access the project file of the sample merchant site codesandbox io/s/virtual-store-sample-fnydk5 click the fork button to create an editable copy of the project next, follow the steps below to register your sample merchant site in the samsung pay developers site go to my projects > service management click create new service select web online payment as your service type enter your service name and select your service country select your payment gateway from the list of supported payment gateways pg if your pg uses the network token mode, upload the certificate signing request csr or privacy enhanced mail pem file you obtained from your pg contact your pg for details enter the payment domain name s for your website in the service domain field and click add for example, if your domain is mywebstore com, but the checkout page is hosted on the subdomain payments mywebstore com, you will need to enter payments mywebstore com as the service domain for each additional domain url, click add in this code lab, the generated preview url of the forked project is your service domain click the name of the newly created service to see its details, such as the generated service id that you can use for all the registered service domains include the samsung pay web checkout javascript sdk the samsung pay web checkout sdk uses javascript to integrate the samsung pay payment system to your website this sdk allows users to purchase items via web browser in the <head> section of the index html file of the project, include the samsung pay web checkout javascript sdk file <script src="https //img mpay samsung com/gsmpi/sdk/samsungpay_web_sdk js"></script> initialize the samsung pay client to initiate payments using the samsung pay api, create a new instance of the paymentclient class and pass an argument specifying that the environment as stage write the code below in the <script> tag of the <body> section const samsungpayclient = new samsungpay paymentclient { environment "stage" } ; when the service is still in debug or test mode, you can only use the staging environment to test payment functionality without processing live transactions noteby default, the service is initially set to debug or test mode during creation to switch the service status to release mode, a request must be made through the samsung pay developers site after successfully transitioning to release mode, change the environment to production next, define the service id, security protocol, and card brands that the merchant can support as payment methods the service id is the unique id assigned to your service upon creation in the samsung pay developers site let paymentmethods = { version "2", serviceid "", //input your service id here protocol "protocol_3ds", allowedbrands ["visa", "mastercard"] }; check whether the samsung pay client is ready to pay using the given payment method call the createandaddbutton function if the response indicates that the client is ready samsungpayclient isreadytopay paymentmethods then function response { if response result { createandaddbutton ; } } catch function err { console error err ; } ; create and implement the samsung pay button go to the <body> section and, inside the page-container div, create a container for the samsung pay button <div align="center" id="samsungpay-container"></div> next, go back to the <script> tag and write the createandaddbutton function inside this function, generate the samsung pay button by calling the createbutton method ensure that the button appears on the page by appending it to the container you created function createandaddbutton { const samsungpaybutton = samsungpayclient createbutton { onclick onsamsungpaybuttonclicked, buttonstyle "black"} ; document getelementbyid "samsungpay-container" appendchild samsungpaybutton ; } function onsamsungpaybuttonclicked { // create the transaction information //launch the payment sheet } from the createandaddbutton function, call the onsamsungpaybuttonclicked function when the user clicks the generated button create the transaction information in the onsamsungpaybuttonclicked function, create the transactiondetail object for the user’s purchase input your service domain in the url key let transactiondetail = { ordernumber "sample0n1y123", merchant { name "virtual shop", url "", //input your service domain countrycode "us" }, amount { option "format_total_estimated_amount", currency "usd", total 2019 99 } }; below are the descriptions of the keys included in the transactiondetail object key type description ordernumber string order number of the transaction allowed characters [a-z][a-z][0-9,-] merchant object data structure containing the merchant information merchant name string merchant name merchant url string merchant domain url e g , samsung com the maximum length is 100 characters merchant countrycode string merchant country code e g , us for united states iso-3166-1 alpha-2 amount object data structure containing the payment amount amount option string display format for the total amount on the payment sheet format_total_estimated_amount = displays "total estimated amount " with the total amountformat_total_price_only = displays the total amount only amount currency string currency code e g , usd for us dollar the maximum length is 3 character amount total string total payment amount in the currency specified by amount currencythe amount must be an integer e g , 300 or in a format valid for the currency, such as 2 decimal places after a separator e g , 300 50 notefor the complete list of specifications for the transactiondetail object, see samsung pay web checkout api reference launch the payment sheet after creating the transaction information, call the loadpaymentsheet method to display the web checkout ui the user can either input their email address or scan the generated qr code a timer screen in the web checkout ui is displayed after the user input, while a payment sheet is launched in the user's samsung wallet app the payment sheet contains the payment card option s and the transaction details when the user confirms their payment on their mobile device, you will receive the paymentcredential object generated by the device then, inform the samsung server of the payment result using the notify method the paymentresult object contains the payment result information during transaction processing and after the payment is processed with the pg network notefor real transactions, you need to extract the payment credential information from the 3ds data key within the paymentcredential object and process it through your payment provider however, in this code lab, you only need to print the paymentcredential to the console samsungpayclient loadpaymentsheet paymentmethods, transactiondetail then function paymentcredential { console log "paymentcredential ", paymentcredential ; const paymentresult = { status "charged", provider "test pg" }; samsungpayclient notify paymentresult ; } catch function error { console log "error ", error ; } ; other possible values of the status key are charged - payment was charged successfully canceled - payment was canceled by either the user, merchant, or the acquiring bank rejected - payment was rejected by the acquiring bank erred - an error occurred during the payment process test the samsung pay button after integrating the samsung pay web checkout service into your sample merchant site, follow the steps below to test the functionality of the integrated service open your sample merchant site in a new tab then, click the pay with samsung pay button in the web checkout ui, enter the email address of your samsung account to send a payment request to samsung pay tap the push notification sent to the samsung wallet app installed on your mobile device then, click accept when the payment sheet is loaded, tap on pin and enter your pin to proceed a verified message will display in both the samsung wallet app and web checkout ui to indicate that the payment was processed successfully you're done! congratulations! you have successfully achieved the goal of this code lab topic now, you can integrate the samsung pay web checkout service into your website by yourself if you're having trouble, you may check the complete code below codesandbox io/s/virtual-store-complete-dkhzfx to learn more about developing apps for samsung pay devices, visit developer samsung com/pay
events mobile
blogthanks to everyone who came to samsung developer conference last week or tuned in to the livestream! here were some of our favorite moments that weren't covered in the day 1 and day 2 recaps. code lab code lab sat in the center of tech square and allowed devs to get hands-on experience with the latest sdks and developer tools. samsung engineers were there for support and fun coding challenges gave attendees the chance to win exclusive prizes. penup the penup app is a social network for designers on the galaxy smartphone. you can learn how to draw digitally by tracing on top of a video clip or background image – it's a cool way to turn photos into masterpieces! the penup team secured two digital artists for sdc19. the artists roamed around and used a tab s6 and s pen to sketch attendees and capture the action at sdc19. there were also great tutorials on the s pen and s pen sdk in tech square! laugh and learn senior developer evangelist tony morelan and comedian corey rosen had a high-energy comedy and improv presentation on day 1 called galaxy watch face design from concept to completion. attendees and designers collaborated in real time to create an interactive galaxy watch face. it was a fun experiment that demonstrated how easy it is to design without coding. the audience was able to quickly create a playful watch face. fit @ sdc one theme of sdc19 was collaboration. samsung is forging new partnerships with brands to help devs have more tools at their disposal and reach a wider audience. two such partners are under armour and skimble, and each morning they put together a wellness activity that featured their new galaxy store apps. day 1: yoga-centric exercise class with skimble this class was led by a trainer from made for samsung partner skimble. yoga mats and samsung galaxy watch active2s were available for attendees, and they could download the workout trainer by skimble app to follow along with a samsung-specific workout. everyone was able to monitor their heart rate on the watch while getting their move on! day 2: fun run/walk with under armour under armour organized a two-mile walk or three-mile run for attendees before the conference. samsung galaxy watch active2s were given to participants and synced with the map my run app to track their distance, pace, and calorie burn. devs, we hope that sdc19 inspired you to continue innovating. from troubleshooting to new platform training, the samsung developer program is always here to help. check out our post-event site with more highlights, photos, and videos of sdc19. we hope to see you next year!
Samsung Developer Program
web
sitemap learn code lab foldables and large screen one ui beta develop see all mobile products galaxy gamedev galaxy themes galaxy watch health samsung blockchain samsung dex samsung iap samsung internet samsung wallet visual display smart tv smart hospitality display smart signage digital appliance family hub platform bixby knox smartthings tizen.net design design system one ui one ui watch smart tv distribute galaxy store tv seller office galaxy store games instant plays support dev support remote test lab samsung android usb driver galaxy emulator skin connect blog news event forum samsung developer conferences
Learn Code Lab
codelabdevelop a smartthings find-compatible device objective learn how to create your own smartthings find-compatible device using the smartthings find partnership program device sdk learn how to measure the radio frequency rf performance of a bluetooth low energy ble device using tag toolbox partnership request the smartthings find partnership program is available only to registered partners who wish to commercialize you can only do this code lab and get the resources after a successful partnership to form a partnership, contact partners@smartthings com overview the smartthings find partnership program comprises smartthings find device specification, smartthings find device sdk, test tool, and technical support it facilitates the development of devices operating with smartthings find services and mobile applications the smartthings find device sdk is small enough to work on resource-limited microcontroller unit mcu devices in this code lab, you can learn how to develop your own smartthings find device first, you can know how to set up your project in smartthings using the developer workspace next, you can learn how to build your firmware with smartthings find device sdk lastly, you can know how to check the functionalities of your device's rf performance using the tag toolbox app set up your environment you will need the following host pc running on windows 11 visual studio code as the ide smartthings find device sdk code smartthings find tag toolbox smartthings app toolchain for nrf52833 dk use the ncs nrf connect sdk version 2 6 1 nrf52833 dk with buzzer module and nfc antenna galaxy smarttag2 register and deploy to test your device using the smartthings developer workspace, you can create a device profile, customize the instructions for onboarding the device on the smartthings app, and test the devices by deploying them you can edit the configurations until you submit the device for publication in the smartthings ecosystem sign in to smartthings developers go to smartthings developer workspace and sign in using your samsung account select a project and add a device profile select stfind codelab example and check its device profile under the device profile, specify whether the device operates on ble ble and uwb afterward, you can customize your device's onboarding experience in smartthings by uploading your product images, user instructions, and brand name under device onboarding lastly, you can fill in basic product information in the product info deploy your device to test after you complete all of these, you can go back to the overview tab and press deploy to test you can download the tagonboardingconfig h file which includes your project configuration the sdk code needs this configuration file register your devices you can add the identity of your device in the smartthings cloud for authentication this requires device information like serial number and device public key ed25519 when you reach the maximum number of test devices per user, remove the existing ones this example shows how to create an ed25519 key pair with sdk tools in visual studio code, press the tagkeygen button at the bottom afterward, you can generate the serial number, private key, and public key register it to the smartthings cloud using the smartthings developer workspace and include it in your firmware after checking the created information on visual studio code go to the developer workspace go to test > test devices menu, and click register new device input the generated serial number and public key build the firmware with the sdk open visual studio code and build the firmware for your device open the sdk project in the file explorer of visual studio code, you can find four code lab files here when you click the nrf connect icon, it shows important functions such as build, flash, and serial log check the configuration files ensure that two essential configuration files are applied tagonboardingconfig h tagdeviceinfo h write your code in main c, complete the code to call the taginit and tagstart apis of device sdk you can find code_mission in the source code and follow the instructions in the code by simply removing the comments #include <zephyr/zephyr h> #include <zephyr/sys/printk h> #include "tagsdk h" #include "mbedtls/aes h" static void init_aes_table void { mbedtls_aes_context dump_ctx; unsigned char dump_key[16]; mbedtls_aes_setkey_enc &dump_ctx, dump_key, 128 ; } void main void { int err = 0xff; tagresult_t result = tag_result_not_supported; /** * code_mission * you will check this serial log later in this codelab */ printk "tag demo! %s-%s-%s\n", config_board, __date__,__time__ ; init_aes_table ; /** * code_mission * call taginit api by removing comment // * * by calling this api, tag sdk will load nv, set rtc and * initialize crypto, and so on * you shall initialize bsp before call this api * services and starts ble advertising */ // result = taginit ; if result != tag_result_success { printk "failed to init %d\n", result ; return; } err = bt_enable 0 ; if err { printk "failed to init bt %d\n", err ; return; } /** * code_mission * call tagstart api by removing comment // * * by calling this api, tag sdk will initialize ble gatt * db and services and starts ble advertising * you shall initialize ble stack before call this api */ // result = tagstart ; if result != tag_result_success { printk "failed to start maintask %d\n", result ; return; } } in portnfc c, call the seturl function you can find code_mission in the source code and follow the instructions in the code by simply removing the comments tagerror_t portnfcseturl char *url, size_t urllen { tagerror_t ret = tag_error_none; ret = disablenfc ; if ret != tag_error_none { tag_log_e "failed to disable nfc" ; return ret; } /** * code_mission * remove comment // below to call seturl function */ // ret = seturl url, urllen ; if ret != tag_error_none { tag_log_e "failed to set url message" ; return ret; } ret = enablenfc ; if ret != tag_error_none { tag_log_e "failed to enable nfc" ; return ret; } return tag_error_none; } build go to nrf connect > actions click on build noteit may take some time for the build to finish you can see the progress by checking the popup at the bottom-right corner of the ide you can also select nrf connect build in the terminal to check the detailed status flash connect the nrf52833 dk to your computer go to nrf connect > actions click on flash once completed, you can hear a notification sound from your device check the serial log of your device go to nrf connect > connected devices click the plug icon on the right side of vcom0 comxx at the top of the ide, select the first item in the list under connected devices press the reset button briefly on your device by checking the timestamp from the serial log, you can verify whether your device successfully downloaded the firmware onboard and control your device via smartthings app onboard your device launch the smartthings app tap the + icon at the top right of the screen click on add device select add in the partner devices section select my testing devices then, select stfind codelab example to start onboarding allow the use of location information and press agree verify your device by pressing the button on the board in the success! page, tap on done to finish onboarding your device locate and ring your device tap on view map to show the location of your device select ring and your device produces a sound through its buzzer module you may switch to either high-volume or low-volume ringing press stop to stop the ringing configure the lost mode of your device when lost mode is activated, it allows you to view a lost message showing the owner's contact information and any personalized messages in the smartthings app, tap on view map > more > lost mode in the lost mode page, select next add email, contact, and message information then, tap on turn on test it by placing an nfc device or a mobile device at the nfc antenna of your device a lost message should show on your mobile device test the device's rf performance via tag toolbox smartthings find tag toolbox allows you to measure the rf performance of a ble device and log the results create a new test item launch the tag toolbox app on a mobile device tap on ble performance > add new test to create a new test item select a target device and a reference device to compare rf performance a target device this is your device created through this code lab b reference device this is the smarttag2 as a comparison target conduct rf performance tests press start session and check your device's rf performance once completed, tap on take a picture and capture how far away the mobile device is from both your device and the smarttag2 tap on test result to find out your device's rf performance export test result test reports can be exported as a file either during the test or after completing the test check your device's rf performance in the list of session menu a min rssi minimum value of your device's rf signal b max rssi maximum value of your device's rf signal c packet detection rate if the advertising transmission interval is two seconds, it indicates how many packets were detected during the test duration press export test result and it shows the location of the file on your mobile device you're done! congratulations! you have successfully achieved the goal of this code lab topic now, you can develop your own smartthings find-compatible devices to form a partnership, contact partners@smartthings com
Learn Code Lab
codelabimplement app continuity and optimize large screen ui of a gallery app objective learn how to apply app continuity and large screen optimization on a gallery app for seamless experience on foldable devices overview samsung foldable devices have two different physical screens the cover display and the larger main display app continuity lets you experience a seamless transition between these displays when using an app that supports app continuity, you can unfold the device and continue where you left off with this feature, apps can run without interruption when it receives a configuration change event, such as when a device is folded or unfolded it is essential to continue the operation by keeping the same state and location of the app after the transition large screen optimization plays another significant role in terms of ux designing for foldable devices the screens of foldable devices have a wide range of aspect ratios, careful ux design is needed to suit two different size displays set up your environment you will need the following java se development kit jdk 8 or later android studio latest version recommended samsung galaxy fold, z fold2, z fold3, or newer remote test lab if physical device is not available requirements samsung account java runtime environment jre 7 or later with java web start internet environment where port 2600 is available sample code here is a sample code for you to start coding in this code lab download it and start your learning experience! app continuity sample code 2 80 mb start your project after downloading the sample code containing the project file for this code lab, open your android studio and click open an existing project locate the downloaded android project from the directory and click ok handle the configuration change to have a seamless experience when using a gallery app, the photo that is displayed after folding or unfolding the device should be the same as the previous you need to store the position or id of the photo, as android destroys and recreate the activity when folding and unfolding the phone use bundle with its key/value pair to store and restore the values in addition, you need to consider the screen rotation in order to keep the app running, as android restarts the activity of the app after the configuration changes let's first start to prevent the activity from restarting, by handling the configuration change for mainactivity in androidmanifest xml file android configchanges="keyboardhidden|orientation|screensize" save the instance state by storing the data before the activity is destroyed when the screen changes from main to cover display or vice versa, android provides us an override method called onsaveinstancestate it accepts a bundle as a parameter use putint method to store data into key/value pair override fun onsaveinstancestate outstate bundle { outstate putint "currentposition", currentimageposition log i "tag", "onsave "+currentimageposition super onsaveinstancestate outstate } retrieve the stored values when the app is first developed, the savedinstancestate will be null inside the oncreate method if it is not null, you can retrieve the stored values from the bundle using getint and the key name you set up in the previous step while storing if savedinstancestate != null { selectedimageview!! setimageresource images[savedinstancestate getint "currentposition" ] customgalleryadapter!! updateposition images[savedinstancestate getint "currentposition" ] currentimageposition = savedinstancestate getint "currentposition" log i "tag", "onsaved " + savedinstancestate getint "currentposition" } create a layout file for the main display the next thing to do, is to optimize the app's large screen ui here, you will add a navigator for the photos when using the app in the main display, since it has more space android offers an alternate resources option based on various criteria like display size, density, and other more you can use two different layout files for each display using alternate resources of android create a new directory in res in the form of [resource]-[qualifier] for cover display and main display the appropriate version of the resource is shown automatically by the system based on the smallest width qualifier of sw the cover display will be between sw240 and sw480, while the main display will be sw600 create a new directory named layout-sw600dp under the res directory and then create an xml file named activity_main res/ layout/ activity_main xml layout-sw600dp/ activity_main xml add the layout code add the gallery layout code shown below, in layout-sw600dp/activity_main xml file <?xml version="1 0" encoding="utf-8"?> <androidx constraintlayout widget constraintlayout xmlns android="http //schemas android com/apk/res/android" xmlns app="http //schemas android com/apk/res-auto" xmlns tools="http //schemas android com/tools" android id="@+id/linearlayout" android layout_width="match_parent" android layout_height="match_parent" tools context="com xyz gallery mainactivity"> <imageview android id="@+id/imageview" android layout_width="wrap_content" android layout_height="match_parent" android gravity="center_vertical" app layout_constraintend_toendof="parent" app layout_constraintstart_tostartof="parent" app layout_constrainttop_totopof="parent" /> <gallery android id="@+id/allgallery" android layout_width="fill_parent" android layout_height="108dp" android layout_marginbottom="4dp" android gravity="fill" android orientation="horizontal" android padding="10dp" android spacing="5dp" app layout_constraintbottom_tobottomof="parent" app layout_constraintend_toendof="parent" app layout_constrainthorizontal_bias="0 0" app layout_constraintstart_tostartof="parent" /> </androidx constraintlayout widget constraintlayout> run the app after building the apk, you can run the gallery app and see how it change when you fold and unfold the device if you don’t have any physical device, you can also test it on a remote test lab device tipwatch this tutorial video and know how to easily test your app via remote test lab noteapp continuity when folding the device, can be turned on for selected apps in settings if the app supports app continuity to continue using the gallery app on the cover display when you close your phone, go to settings> display > continue apps on cover screen > toggle on gallery app foldable devices let you decide whether you want to see less or more content at the same time in the main display to see the photo navigator added in the app, go to settings> display > screen layout and zoom > see more content at the same time you're done! congratulations! you have successfully achieved the goal of this code lab now, you can optimize your app to support continuity and large screen layout by yourself! if you're having trouble, you may download this file app continuity complete code 24 44 mb to learn more about developing apps for galaxy foldable devices, visit www developer samsung com/galaxy-z
Connect Samsung Developer Conference
websession contents & service, developer program, mobile add samsung pay as your payment method in this session, we will share learnings from our experience developing the samsung pay mobile payment service, revealing insights that can be applied to your own platforms. we will also take a look at the samsung pay development kit and how you can use this for your own service. speakers minji lee samsung code lab sdc22 integrate in-app payment with merchant apps learn how to integrate in-app payment with your merchant apps using samsung pay sdk. 45 mins start
Learn Code Lab
codelabuse ar emoji on games and 3d apps objective learn how to use ar emoji as character of games or 3d applications using galaxy ar emoji sdk for unity partnership request to use the galaxy ar emoji sdk for unity, you must become an official samsung partner once done, you can fully utilize this code lab you can learn more about the partnership process by visiting galaxy ar emoji sdk page, here in samsung developers overview galaxy ar emoji sdk for unity with your samsung galaxy device, you can use the ar emoji feature to create an animated 3d avatar from your selfie photo or from a selection of a few suggested characters the avatar can display a range of emotions and body movements the galaxy ar emoji sdk for unity enables you to use this said ar emoji avatar in your application, such as using it to represent a game character tutorial process in this code lab, you will get to know about unity packages that can help you to use ar emoji avatars as character models in your unity application like games with simple code updates you will first learn about the basic pipeline for creation of app with ar emoji character with ar emoji sdk by loading a character model and rendering on the mobile app afterwards, you will learn a way of applying custom animation to the ar emoji character you can make your own app with a simple sequence of operation and by following the steps in this code lab moreover, you can learn about the character file import process and get to know more how you can maximize galaxy ar emoji sdk set up your environment you will need the following unity for windows lts release 2020 3 xf1 or latest compatible version editor for editing unity script like visual studio select different values to test how your game will look on monitors with different aspect ratios this is set to free aspect by default recommended 1024x2048 samsung galaxy device supporting ar emoji create your own ar emoji first, create your own ar emoji with the following steps run camera application click more > ar zone > ar emoji camera and the + button take your selfie and choose your gender edit your ar emoji a customize the looks, clothes, or accessories of your ar emoji b press next, once done check your avatar in both mask mode and in ar emoji studio create a unity project and configure the settings run unity and create an empty 3d sample project go to build settings a file > build settings b platform > android c click switch platform specific package name and keystore are necessary for testing in the next steps, it is explained in detail go to edit > player settings > player > other settings > identification > override default package name and enable it set the package name to samsung com fileprovidersample go to edit > project setting > player > publishing settings a enable custom keystore b add keystore file fileprovidersample jks with browser included in docs folder of gettingaremojiv3 3 unitypackage c enter the keystore password 123456 d set the project key setting alias keyalias password 123456 import packages run gettingaremojiv3 3 unitypackage, then click import check the imported sample app a go to assets > scenes > gettingaremojisample scene b click canvas import the next package, gltfimporterv3 3 unitypackage integrate the gltf importer to the sample app go to the sample scene a click assets > scenes > gettingemojisample unity b click canvas copy gltfcomponent prefab into your app to use gltf component property a click assets > prefabs b drag gltfcomponent prefab to your scene build and run go to file > build settings > build and run launch the sample app in your device a click getavatarlist button and check the ar emoji list stored on the device b select one of them c click getavatarthumbnailuri button d confirm if the ar emoji thumbnail is showing e click getavatarzipuri button f check if it shows the ar emoji avatar learn the basics of animation in unity animation system overview unity has a rich and sophisticated animation system sometimes referred to as mecanim while mecanim is recommended for use in most situations, unity has retained its legacy animation system, which existed before unity 4 when working with an older content created before unity 4, you may need to use the legacy animation system animator controller to apply the animation to the model, you must have a basic knowledge of the animation controller developers can easily control the animation with it an animator controller allows you to arrange and maintain a set of animation clips and associated animation transitions for a character or object in most cases it is normal to have multiple animations and switch between them when certain game conditions occur for example, you could switch from a walk animation clip to a jump animation clip whenever the space bar is pressed however, even if you only have a single animation clip, you still need to place it into an animator controller to use it on a gameobject the animator controller has references to the animation clips used within it, and manages the various animation clips and the transitions between them using a state machine, which could be thought of as a flow-chart of animation clips and transitions, or a simple program written in a visual programming language within unity here, the model is a loaded runtime, and then an animation controller component is added to the model therefore, you will learn how to make an animation clip and apply a simple animation through a state machine animation state machine unity’s animation state machines provide a way to see the overview all of the animation clips related to a particular character and allow various events in the game, such as user inputs, to trigger different animations state machine transitions exist to help you simplify complex state machines this allows you to have a higher level of abstraction over the state machine logic each view in the animator window has an entry and exit node the animator window specifies the state machine transitions the entry node is used when transitioning into a state machine it will be evaluated and will branch to the destination state according to the conditions set in this way, the entry node can control which state the state machine begins in, by evaluating the state of your parameters when the state machine begins because the state machine always has a default state, there will always be a default transition branching from the entry node to the default state humanoid animations unity’s animation system also has numerous special features for handling humanoid characters which give you the ability to retarget humanoid animation from any source to your own character model, as well as adjusting muscle definitions these special features are enabled by unity’s avatar system, where humanoid characters are mapped to a common internal format one of the most powerful features of mecanim is retargeting of humanoid animations this means that with relative ease, you can apply the same set of animations to various character models retargeting is only possible for humanoid models, where an avatar has been configured because this gives a correspondence between the models’ bone structure generate animation clips animation clips are one of the core elements to unity’s animation system unity supports importing animation from external sources, and offers the ability to create animation clips from scratch within the editor using the animation window animation data collection this code lab provides a tool that works with the model before then, you need animation data it can be made directly with a professional tool like maya and 3ds max or it can be obtained for free from mixamo make the character walk get the animation data here from mixamo a select the walking animation data b click the download button c the download settings appears and the animation data can be obtained by setting the following transfer the file to unity this allows you to set the following settings in the inspector window after changing the animation type to humanoid, click the apply button it is automatically retargeted to the unity avatar system the animation controller is basically set in the model a in resources > animations > avatar > controller, double click the player controller, then you can see the animator window b the animation set by default is gangnam style it’s recommended to change this to ik idle c next, apply the animation by dragging the walking animation to the button make the transition from idle to walk a right-click the idle node b connect lines from idle node to the walk node select the connecting line for transition idle → walk a uncheck has exit time b set the parameter to bool animation parameters are variables that are defined within an animator controller that can be accessed and assigned values from scripts this is how a script can control or affect the flow of the state machine c add the condition of transition idle → walk select the connecting line for transition walk → idle repeat in the same way with previous steps however, the condition of walk should be set to false look for the button behaviour script in buttonbehaviour cs, write a script that modifies parameters based on user input add the following at the bottom of the existing code public animator anim; public float speed = 1 0f; // update is called once per frame void update { if input getkey keycode space { if anim == null { if gameobject findgameobjectwithtag "gltfcomponent" { debug log "find gltfcomponent" ; gameobject o = gameobject findgameobjectwithtag "gltfcomponent" ; gltfcomponent = o getcomponent<unitygltf gltfcomponent> ; } anim = gltfcomponent getcomponent<animator> ; } } if input getkey keycode rightarrow { gltfcomponent transform rotation = quaternion euler 0, 90, 0 ; gltfcomponent transform position += gltfcomponent transform forward * time deltatime * speed; anim setbool "walk", true ; } else if input getkey keycode leftarrow { gltfcomponent transform rotation = quaternion euler 0, -90, 0 ; gltfcomponent transform position += gltfcomponent transform forward * time deltatime * speed; anim setbool "walk", true ; } else if input getkey keycode downarrow { gltfcomponent transform rotation = quaternion euler 0, 180, 0 ; gltfcomponent transform position += gltfcomponent transform forward * time deltatime * speed; anim setbool "walk", true ; } else if input getkey keycode uparrow { gltfcomponent transform rotation = quaternion euler 0, 0, 0 ; gltfcomponent transform position += gltfcomponent transform forward * time deltatime * speed; anim setbool "walk", true ; } else{ anim setbool "walk", false ; } } play and review the walking animation in the unity studio a press the spacebar on your keyboard and now you can operate the animation you set b try pressing the arrow keys of the keyboard, to make your ar emoji character move using the walking animation you're done! congratulations! you have successfully achieved the goal of this code lab now, you can create an ar emoji avatar and use it as a character in games or apps, all by yourself! learn more by going to galaxy ar emoji
Learn Code Lab
codelabintegrate iot devices into the smartthings ecosystem objective learn how to create your own iot device using smartthings sdk for direct connected devices overview the smartthings sdk for direct connected devices is provided to ease the development of devices which operate with smartthings cloud and mobile application it is small enough to work on resource limited embedded devices in this code lab, you will learn how to create your own iot device profile at smartthings cloud and how to implement on your test device it is explained into three parts the first explains how you can register and deploy to test your own iot device profile in smartthings using the developer workspace then, it demonstrates how to create your own iot device application with smartthings sdk the last part shows how to onboard and control instances of your device with smartthings mobile application noteyou will name the device as code lab example for this tutorial set up your environment you will need the following host pc this code lab is based on ubuntu linux x64 toolchain and board support package bsp for micro-controller unit mcu board you will use the esp32-c3-devkitc board you may set up the environment by referring to this github repository github repositories for the library and references or samples of smartthings sdk for direct connected devices for c $ git clone https //github com/smartthingscommunity/st-device-sdk-c-ref git $ cd st-cevice-sdk-c-ref $ python3 setup py esp32 smartthings mobile application sample code here is a sample code for you to start coding in this code lab download it and start your learning experience! smartthings sdk sample code 2 60 kb register and deploy to test your device using the developer workspace, create a device profile and customize the instructions for onboarding the device on the smartthings mobile app, and deploy devices to be tested these configurations can be edited up until the point you submit the device for publication in the production of the smartthings ecosystem sign in to smartthings developers sign in to smartthings developer workspace using your samsung account create new project you need to create an integration project for a direct connected device create a new device project for device integration select device integration, then direct-connected afterwards, name your project respectively add a device profile define your device’s functionalities with smartthings capability first, navigate and select define device profile and then click create device profile fill the required fields with respective values afterwards, select a capability for your device you can get more information about the capabilities available here notethe health check capability is automatically added for all direct connected devices it should not be removed the required capabilities are switch and health check add device onboarding the device onboarding guides device owners when their device is first registering and connecting to smartthings you can customize the screens presented by adding a device onboarding profile the ownership validation type is also defined at this stage you may customize the screens displayed when the device onboards via the smartthings mobile app, or just use the default values noteuse just works or button confirm for this example add a product info the product info defines how this device is shown at smartthings mobile app catalog you can define device’s category and its regional availability deploy your device to test you can start testing by deploying your device to test there are two ways to do this via overview menu via test > test devices you will be able to see your device in the smartthings mobile app when in developer mode only after it has been deployed for testing register test devices you can add the identity of device for authenticating it to the smartthings cloud this requires device information like serial number and device public key ed25519 since the maximum number of test device is limited per user, once you’ve reached it, you should remove the existing one this example shows how to create ed25519 key pair with sdk tools you can get device_info json file as a result from tools/keygen/linux/output_{ serialnumber} linux version of key generator keygen utility is located at st-iot-device-sdk-c-reference/iot-core/tools/keygen/ or st-device-sdk-c/tools/keygen/ serial number for testing device would be randomly generated by this tool which has stdk + 12-digit alphanumeric format $ cd ~/workspace/st-device-sdk-c-ref/iot-core/tools/keygen/ $ python3 stdk-keygen py –firmware switch_example_001 use following serial number and public key for the identity of your device in developer workspace serial number stdk**e90w***ucx public key nfn5x***uqusq****zhobsfaaop9***kndlnjdjrew= copy stdk**e90w***ucx from keygen output and paste it into serial number field of register a test device page copy public key string from keygen output nfn5x***uqusq****zhobsfaaop9***kndlnjdjrew= in this example and paste it into public key field generate device qr code using the device qr code could be helpful while device onboarding qr code should have format like below refer here for more details urlhttps //qr samsungiots com/?m={your mnid}&s={device onboardingid}&r={device serialnumber} {your mnid} 4-digit alphanumeric mnid of your account {device onboardingid} 3-digit number onboarding id, you can find it from your developer workspace project device onboarding > other info page {device serialnumber} device serial number which is registered at your developer workspace project you can simply generate qr code with using below python script import qrcode mnid = 'ffff' # "ffff" is an example you should replace it with yours onboardingid = '111' # "111" is an example you should replace it with yours serialnumber = 'stdktest0001' # "stdktest0001" is an exmaple you should replace it with yours qrurl = 'https //qr samsungiots com/?m=' + mnid + '&s=' + onboardingid + '&r=' + serialnumber img = qrcode make qrurl img save serialnumber + ' png' qrcode qrcode box_size=10, border=4 write device application open and edit sample device app currently, you are doing the code lab example, which is located at apps/esp32/code_lab_example directory in the github repository download onboarding_profile json from the overview of your device in developer workspace copy onboarding_profile json file into your application directory, apps/esp32/code_lab_example/main $ cd ~/workspace/st-device-sdk-c-ref/apps/esp32/code_lab_example/main/ $ cp ~/downloads/onboarding_config json copy device_info json from tools/keygen/linux/output_{serialnumber} which contains your device specific information to application directory, apps/esp32/code_lab_example/main $ cd ~/workspace/st-device-sdk-c-ref/iot-core/tools/keygen/ $ cp output_{serialnumber}/device_info json ~/workspace/st-device-sdk-c-ref/apps/esp32/code_lab_example/main/ firmwareversion version string privatekey base64 encoded ed25519 private key this value should be paired with what you registered to developer workspace publickey base64 encoded ed25519 public key this value should be same with what you registered to developer workspace serialnumber this value should be same with what you registered to developer workspace { "deviceinfo" { "firmwareversion" "switch_example_001", "privatekey" "dh**jkmrd5x****bav+fgoxa3qzfnw3v****jhxomd0=", "publickey" "nfn5x***uqusq****zhobsfaaop9***kndlnjdjrew=", "serialnumber" "stdk**e90w***ucx" } } open sample application source code browse in apps/esp32/code_lab_example/main/ directory open main c file write your device application code this example already has cloud connection functionality using smartthings sdk apis void app_main void { /** easily integrate your direct connected device using the direct connected devices sdk the sdk manages all mqtt topics and onboarding requirements, freeing you to focus on the capabilities of your device that is, you can simply develop a basic application by just calling the apis provided by st_iot_core layer like below // create a iot context 1 st_conn_init ; // create a handle to process capability 2 st_cap_handle_init ; called in function 'capability_init' // register a callback function to process capability command when it comes from the smartthings server 3 st_cap_cmd_set_cb ; called in function 'capability_init' // process on-boarding procedure there is nothing more to do on the app side than call the api 4 st_conn_start ; */ unsigned char *onboarding_config = unsigned char * onboarding_config_start; unsigned int onboarding_config_len = onboarding_config_end - onboarding_config_start; unsigned char *device_info = unsigned char * device_info_start; unsigned int device_info_len = device_info_end - device_info_start; int err; iot_gpio_init ; xtaskcreate app_main_task, "app_main_task", 4096, null, 10, null ; //create a iot context iot_ctx = st_conn_init onboarding_config, onboarding_config_len, device_info, device_info_len ; if iot_ctx != null { err = st_conn_set_noti_cb iot_ctx, iot_noti_cb, null ; if err printf "fail to set notification callback function\n" ; } else { printf "fail to create the iot_context\n" ; } //create a handle to process capability and initialize capability info capability_init ; //connect to server err = st_conn_start iot_ctx, st_status_cb &iot_status_cb, iot_status_all, null, null ; if err { printf "fail to start connection err %d\n", err ; } } complete your command callback function for each capability the command callback function should contain your device control upon each command such as led on or off control capability example for each capability would be helpful to handle attribute command for each capability you can find it at apps/capability_example/main static void update_switch_state int switch_state { const char* switch_value; if switch_state == switch_on { switch_value = caps_helper_switch attr_switch value_on; } else { switch_value = caps_helper_switch attr_switch value_off; } //todo set switch attribute value and send // // example //=============================================================================== // cap_switch_data->set_switch_value cap_switch_data, switch_value ; // cap_switch_data->attr_switch_send cap_switch_data ; //=============================================================================== } static int get_switch_state void { const char* switch_value; int switch_state = switch_off; //todo get switch attribute value // // example //=============================================================================== // switch_value = cap_switch_data->get_switch_value cap_switch_data ; // // if !strcmp switch_value, caps_helper_switch attr_switch value_on { // switch_state = switch_on; // } else if !strcmp switch_value, caps_helper_switch attr_switch value_off { // switch_state = switch_off; // } //=============================================================================== return switch_state; } static void cap_switch_cmd_cb struct caps_switch_data *caps_data { int switch_state = get_switch_state ; set_led_mode switch_state ; } static void capability_init { //todo initialize switch capability with using capability sample's initializae function // // example // //=============================================================================== // cap_switch_data = caps_switch_initialize iot_ctx, "main", null, null ; // if cap_switch_data { // const char *switch_init_value = caps_helper_switch attr_switch value_on; // // cap_switch_data->cmd_on_usr_cb = cap_switch_cmd_cb; // cap_switch_data->cmd_off_usr_cb = cap_switch_cmd_cb; // // cap_switch_data->set_switch_value cap_switch_data, switch_init_value ; // } //=============================================================================== } build, flash, and monitor you can build, flash, and monitor in the console with the following $ cd ~/workspace/st-device-sdk-c-ref $ python3 build py apps/esp32/code_lab_example $ python3 build py apps/esp32/code_lab_example flash $ python3 build py apps/esp32/code_lab_example monitor or $ cd ~/workspace/st-device-sdk-c-ref $ python3 build py apps/esp32/code_lab_example flash monitor onboard and control the device via smartthings app onboarding a enable developer mode developer mode should be enabled on smartthings mobile application launch the smartthings app, go to dashboard > settings long-press about smartthings for 20 seconds enable the developer mode, then restart the smartthings app you can find out more information here b add a new device go to add device and click my testing devices or scan qr code you can now see and add your self-published devices control by smartthings application a device control from dashboard you can turn your device’s led on or off by clicking the button in the smartthings app b device control from plugin you can control various attributes and get more detailed information from the device plugin user interface you're done! congratulations! you have successfully achieved the goal of this code lab now, you can control your iot devices using the smartthings app all by yourself! if you're having trouble, you may download this file smartthings device sdk complete code 2 49 kb
Learn Code Lab
codelabestablish a health research system using samsung health research stack objective learn how to create a health research system that collects data from mobile and wearable devices and visualizes the collected data in a web portal using samsung health research stack overview samsung health research stack is an open-source toolset that helps collect and analyze data from devices in android and wear os environments it provides tools and infrastructure for developing and deploying health studies, ranging from medical research to clinician services and more the framework consists of four components backend services - offers api endpoints to access and interact with a robust data engine web portal - a customizable interface for creating surveys, managing team members, tracking subjects, and analyzing data app sdk - an sdk for building android and wear os apps capable of collecting data from wearable devices starter app - a health research app with mobile and wearable versions created using basic features provided by the app sdk for detailed information, see samsung health research stack set up your environment you will need the following android studio latest version recommended samsung galaxy mobile device with updated health connect app and samsung health app installed samsung galaxy watch synced to the mobile device docker desktop sample code to start your learning experience, download the project files of the samsung health research stack starter mobile and wearable app notedepending on your preferred development style, you can either download or clone the repository of the project files to your local computer feel free to edit and customize this project for your own purposes, including this code lab activity set up your galaxy mobile and watch device connect your galaxy mobile device to your pc and enable adb debugging next, connect your galaxy watch to android studio over wi-fi lastly, enable the developer mode of the health platform app on your watch by following these steps a go to settings b tap on apps c select health platform d quickly tap on health platform several times until [dev mode] appears notethe samsung health developer mode is only intended for testing or debugging your application it is not for application users deploy the backend and web portal locally download the backend-config-files zip file and unzip it the folder contains the docker-compose yaml file open the terminal window of docker desktop in the terminal, go to the directory where your docker-compose yaml file is located, and run the following command $ docker compose up –d the script deploys the backend and the web portal to your local computer, and it includes 6 services redis - redis watcher for the backend casbin service mongo - for saving data from the backend postgres - for supertokens database and the backend casbin database supertokens - for username and password authentication backend - backend for the samsung health research stack portal - web portal for the samsung health research stack you can change the port number, username, and password for each database with the default setting, you can access the web portal in your browser at localhost 80 the script file has simple settings for easy deployment to add more features, you can change the environment in the docker-compose yaml file's services > backend > environment part set the aws environment variables optional you can enable uploading and downloading features by setting the following aws environment variables aws_bucket_name aws_region aws_access_key_id aws_secret_access_key aws_session_token you can follow the instructions in using the default credential provider chain for setting up aws credentials set google openid connect optional to enable google openid connect oidc login, you can set the following environment variables oidc_google_oauth2_url default "https //oauth2 googleapis com" oidc_google_client_id oidc_google_client_secret oidc_google_redirect_uri you can refer to openid connect for more information about setting google oidc create a new study the health research system has two user groups investigators - conduct research studies and use the web portal for managing studies and analyzing data subjects - participate in studies by answering surveys and performing tasks through the mobile app, as well as collecting health data from wearable apps to start your research study, as an investigator, follow the steps below create an account and sign in to the web portal page you deployed fill out the form with your information on the study collection page, click the create study button noteall enrolled investigators can create a study the creator becomes the study admin in the basic info tab, input the details of the study 5 for the study scope, choose public noteyou can set the study scope as either public or private if you choose private, you need to input a participation code that subjects must enter into the mobile app to join however, for the ease of testing in this code lab, it is recommended to set the scope as public for the study requirements field, you can input any text and click next go to participation requirements tab and select the data types to collect in wear category for this code lab, choose wear accelerometer wear ecg wear heart rate the logo and title of the created study show on the study collection page connect the mobile app to backend system to connect the starter mobile app to the backend system, follow these steps noteto ensure that the galaxy mobile device can connect to the machine where the backend system is deployed, it is recommended to connect both the machine and the mobile device to the same network open the downloaded project file in android studio and go to samples > starter-mobile-app in the local properties file, set the server_address to the ip address of the machine where the backend system is deployed server_address ="input ip address here" tipyou can check your ip address using the command line windows in command prompt, type ipconfig and find the ip address under ipv4 address mac in terminal, type ifconfig and look for the ip address under inet next to en0 next, set the server_port to 50001 if you used the default values in the provided docker-compose yaml file for deployment if not, use the port number you set server_port=50001 set authentication method the app sdk supports three types of authentication methods for registration samsung utilizes samsung account cognito incorporates amazon cognito authentication super-tokens enables anonymous login to allow research participants to register and log in using their personal emails, set the sign_in_mode as super-tokens in the local properties file sign_in_mode="super-tokens" upload wearable data via grpc when synchronizing wearable device data, the app sdk offers two approaches utilizing grpc for high-performance remote procedure calls or synchronization through files each approach has advantages and disadvantages regarding factors such as battery life and server workload however, it is advisable to utilize grpc during local development to configure the mobile application to upload wearable data via grpc rather than files, add the following code in the local properties file enable_upload_wearble_data_by_file=false show the sync button in starter wearable app after configuring the mobile app, modify the wearable app to meet the requirements of your study go to samples > starter-wearable-app and open the local properties file the wearable app features a sync button, which can be displayed or hidden when this button is pressed, it synchronizes the collected data with the backend system instantly to show the sync button, set the value of enable_instant_sync_button as below enable_instant_sync_button=true notethis instant sync feature can negatively affect the battery consumption of both apps, so it is recommended to remove the sync button when you publish your app the samsung health research stack has an optimized data synchronization process that minimizes battery consumption set data measurement parameters you can customize the data collection and storage process of the wearable app by setting the values of the following data measurement parameters passive_data_insert_interval_in_seconds sets the data measurement buffer the buffer saves data in an in-memory database before the interval expires then, at regular intervals, the data from the buffer is stored in persistent memory data_split_interval_in_millis specifies the size of segmented data in persistent memory if these values are not specified, the wearable app uses its default values to verify that the data is being measured and synchronized instantly, you can set the values as follows passive_data_insert_interval_in_seconds=12 data_split_interval_in_millis=30000 run the starter mobile and wearable app after configuring the local properties of both starter apps, build and run your app in android studio by following these steps run the starter mobile app select your mobile app starter-mobile-app from the run configurations menu in the toolbar choose a connected galaxy mobile device as the target device for running the app click run to install the app after installation, clear the app's data run the starter mobile app follow the same steps as for the starter mobile app but select starter-wearable-app instead choose a connected galaxy watch device for running the app allow the app to access physical activity, sensor data, and send notifications when prompted ensure that the galaxy watch is connected with the galaxy mobile device register and join a study since you have set super-tokens as the authentication method, you can now register and log into the app at once open the starter mobile app and sign up with an unregistered email address after logging in and accepting permissions, the app displays the study you created from the web portal tap on the study card to view its details and click join study noteif a study is set to private and you wish to join it, press enter the study code located at the top of the screen and input the assigned participation code in the study code field agree to data collection and terms of research you can see that the sensor data to be collected are dependent upon the selection made in the web portal while creating the study sign and click next to complete the study onboarding process measure and collect health data in the starter wearable app, you can see a list of on-demand measurements that you can contribute to health research for this code lab, choose ecg and click measure follow the onscreen measurement instruction after measuring successfully, scroll to the bottom of the wearable app and press the sync button to synchronize the data with the mobile app in the mobile app, go to data tab, click the more button, and click sync to transfer the collected data to the web portal visualize the collected data in web portal you can display the collected data as a graph in any way you choose for further analysis of the study from the overview page of the study in the web portal, navigate to the dashboard page click on the add chart button provide a title for the chart and select the desired chart type then, edit the chart source choose the database where the data is stored for this code lab, enter the following query to display only the first ten heart rate data from wearheartrate table select * from wearheartrate limit 10 click run query and save select value and timestamp for the value and category columns respectively check the preview of the graph finally, click save to display the graph into the dashboard you're done! congratulations! you have successfully achieved the goal of this code lab now, you can create your own health research system by yourself! to learn more, see samsung health research stack
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.