Filter
-
Content Type
-
Category
Mobile/Wearable
Visual Display
Digital Appliance
Platform
Recommendations
Filter
Learn Code Lab
codelabdevelop a widget for flex window objective learn how to create a calendar widget on the flex window of galaxy z flip5 overview the flex window of galaxy z flip5 provides a wider screen than the previous model, galaxy z flip4 it provides more functionalities, such as having customizable clocks, rich wallpapers, and informative notification list the widget that you are going to develop for this code lab can provide a simple interface by executing simple tasks directly visible on the flex window it can guide users to open their z flip5 to perform complex actions on the main screen set up your environment you will need the following samsung galaxy z flip5 android studio latest version recommended java se development kit jdk 11 or later remote test lab if physical device is not available sample code here is a sample code for you to start coding in this code lab download it and start your learning experience! flex window widget sample code 404 29 kb 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 capsule_samplewidget from the directory and click ok make the appwidgetprovider noteto know the basics about creating a widget in android, you may refer to this android developer guide the android appwidget provider defines the properties of the widget while com samsung android appwidget provider implements the methods of the appwidgetprovider class to make the appwidgetprovider, you need to declare the location of the xml file in androidmanifest xml to do this go to app > manifests and open androidmanifest xml look for the <receiver> tag with the simplecalendarwidgetprovider identifier add the following meta-data just above the </receiver> tag <meta-data android name="android appwidget provider" android resource="@xml/meta_info_calendar_widget" /> <meta-data android name="com samsung android appwidget provider" android resource="@xml/samsung_meta_info_sample_widget" /> set the size of the widget go to app > res > xml and open meta_info_calendar_widget xml add the following attributes to set the size of the flex window and set it as a lock screen android minwidth="352dp" android minheight="339dp" android resizemode="horizontal|vertical" android widgetcategory="keyguard" add the samsung appwidgetproviderinfo meta-data go to app > res > xml and open samsung_meta_info_calendar_widget xml add the following attribute to configure the display of the flex window <samsung-appwidget-provider display="sub_screen"> </samsung-appwidget-provider> start the activity from the widget the launchdisplayid indicates whether the widget is on the cover screen or on the main screen if you want to launch an activity from the widget, simply follow these steps to specify the screen display id go to app > java > com samsung android samplewidget > provider open simplecalendarwidgetprovider kt and assign 0 to the launchdisplayid if you want to display the widget on the main screen, and assign 1 if you want it to run on the flex window here, let's start a calendar activity on the main screen launchdisplayid = main_screen_id allow modification of the widget settings create a widget configuration activity to allow modification of the widget settings the appwidgetproviderinfo object describes the meta-data for the widget, such as its layout and update frequency go to app > res > xml and open meta_info_calendar_widget xml declare the configuration activity in the <appwidget-provider> tag by placing the android configure attribute android configure="com samsung android samplewidget activity editsettingactivity" create ongoing notifications first, enable the code to send notification in simplecalendarwidgetprovider kt in simplecalendarwidgetprovider kt, call the makenotification function from the notificationutil class to provide a notification for the sample widget val notificationutil = notificationutil context val notification = notificationutil makenotification pendingintent getactivity context, 0, intent context, editsettingactivity class java , pendingintent flag_cancel_current or pendingintent flag_immutable , it size notificationutil sendnotification notificationutil notification_id, notification set the notification's properties in the same function in notificationutil kt setsmallicon r drawable ic_cover_screen setcolor color parsecolor "#338577" setcontenttitle “sample widget” setongoing true after creating the notification, it should go to the main window of the flex window you can now check and see that there's an ongoing notification notethis feature only works with one ui 6 0 enable the calendar widget now, you can build the project in android studio and test it on your device to enable the widget in your galaxy z flip5, you have to go to settings > cover screen and tap widgets enable the widget that you've created in this code lab you can now see the widget on the flex window of your galaxy z flip5 check other features of the widget you can also test other features of the widget included in the sample project background of the widget in this code lab, you can check the sample project on how to change the background of the widget to be opaque or transparent vertical scrolling also, vertical scrolling is already implemented in the sample project you can check its implementation in the code this allows you to preview more notifications as possible in the flex window you're done! congratulations! you have successfully achieved the goal of this code lab now, you can develop a widget for the flex window by yourself! if you face any trouble, you may download this file flex window widget complete project 404 27 kb to learn more about developing apps for galaxy foldable devices, visit www developer samsung com/galaxy-z
Learn Code Lab
codelabconfigure an app to enable drag and drop in multi-window objective learn how to implement drag and drop on a note-taking app when in multi-window mode overview in galaxy fold and it's latest versions, the advantage of its larger display is to split its screen and simultaneously use up to three apps in multi-window mode, you can split the screen with one window being the main focus, and the other two windows off to the side all three windows are active, not just the largest one you can multitask in either landscape or portrait mode, giving you even more flexibility when using multi-window, drag & drop is one of the useful features when multitasking drag and drop allows you to easily move data from one app to another to provide users with better multitasking experience on samsung's foldable devices, developers need to optimize their apps to work on multi-window mode 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! multi-window drag & drop sample code 19 27 mb start your project open android studio and click open an existing project locate the downloaded android project simplenotes_dragdrop from the directory and click ok make the app resizable to ensure that the app works in multi-window mode, you need to add an attribute in the manifest’s <activity> element if you set android resizeableactivity to true, the activity can be launched in multi-window or in pop-up view, and adapt different screen size android resizeableactivity= "true" noteif this attribute is set to true, the activity can be launched in split-screen and freeform modes otherwise, it will disable multi-window display remember to handle the changes required to fit your ux in small windows when in multi-window mode for this code lab, you do not need to worry about the ux as it is already handled register a drag event listener in newnote kt, register a drag event listener object by calling setondraglistener for both title and description view of the app title setondraglistener ondraglistener desc setondraglistener ondraglistenerdescription store the action type to a variable declare a variable to store the action type for the incoming event val action int = event getaction get and drop the text data inside the dragevent action_drop, get the item from clipdata and check the mime type if the mime type is set to text/plain, get the text value from the item object and allow the operation of drop otherwise, simply show a toast message val item item = event getclipdata getitemat 0 var mtype = event clipdescription getmimetype 0 if mtype == "text/plain" || mtype== "text/html" { // gets the text data from the item dragdata = item text tostring }else{ toast maketext applicationcontext,"operation not allowed"+mtype,toast length_long show return@ondraglistener true } tipin this code lab, to simplify the demonstration of implementing drag and drop, mime type or media type is set to plain text only run the app after building the apk, you can run the optimized note-taking app and start dragging and dropping texts between apps in multi-window mode if you don’t have any physical device, you can also test it on a remote test lab device notewatch this tutorial video and know how to easily test your app via remote test lab you're done! congratulations! you have successfully achieved the goal of this code lab now, you can implement drag and drop in your app for your foldable device by yourself! if you're having trouble, you may download this file multi-window drag & drop complete code 19 33 mb to learn more about developing apps for galaxy foldable devices, visit www developer samsung com/galaxy-z
Learn Code Lab
codelabimplement flex mode on a video player objective learn how to implement flex mode on a video player app using android jetpack windowmanager overview the galaxy z fold4, or its previous versions, is a foldable phone with a vertical axis that opens like a book at the same time, the galaxy z flip4, or its predecessors, folds horizontally, dividing its screen into upper and lower sections when the phone is partially folded, it is called flex mode unfolding the phone will return the apps in full-screen mode in flex mode, the app's ui separates its controls on the bottom from the rest of the content on the top to fit the partially folded screen when the phone is unfolded, window components reoccupy their original positions to fit the full-screen mode, like usual smartphones it gives an outstanding experience on camera, video calls, multimedia, and other apps to provide users with a convenient and versatile foldable experience, developers need to optimize their apps to meet the flex mode standard set up your environment you will need the following java se development kit jdk 8 or later android studio latest version recommended samsung galaxy foldable device galaxy z fold2, z fold3, or newer galaxy z flip, z flip3, 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! flex mode sample code 15 60 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 videoplayer-main from the directory and click ok add the maven repository and windowmanager library windowmanager, a new jetpack library introduced by google, helps application developers support new device form factors to add a dependency on windowmanager, you must first add the maven central repository to the project go to gradle scripts > build gradle project video_player and enter the following in the allprojects block mavencentral then, go to gradle scripts > build gradle module video_player app and add the windowmanager library to the dependencies block implementation "androidx window window 1 0 0" implementation 'androidx lifecycle lifecycle-runtime-ktx 2 6 1' set up a flow to collect data from windowlayoutinfo in the mainactivity kt, add a lifecycle-aware coroutine to obtain information from windowlayoutinfo the coroutine executes each time the lifecycle starts lifecyclescope launch dispatchers main { lifecycle repeatonlifecycle lifecycle state started { windowinfotracker getorcreate this@mainactivity windowlayoutinfo this@mainactivity collect { newlayoutinfo -> updatestateandfeatureviews newlayoutinfo } } } noteupdatestateandfeatureviews is a user-defined function and is not included in the windowmanager library in this code lab, it needs to be called to check the device posture determine the device posture and update the ui next, in the updatestateandfeatureviews function, check the current posture of the device and update the ui accordingly for flex mode when the device is currently folded, the displayfeatures is null if newlayoutinfo displayfeatures isempty when the device is currently in flex mode or partially folded, the device posture is half_opened using the device posture and orientation, implement your flex mode ui if it state == foldingfeature state half_opened && it orientation == foldingfeature orientation vertical { updateuiforfold }else if it state == foldingfeature state half_opened && it orientation == foldingfeature orientation horizontal { updateuiforflip } notethe device orientation of a galaxy fold device is vertical, whereas a galaxy flip's device orientation is horizontal when the device is unfolded, the device posture is flat else if it state == foldingfeature state flat run the app after building the apk, you can run the optimized video player app on a foldable galaxy device and see how it adapts when the device is on flex mode however, if you don't have a physical device, you can test it on a remote test lab device watch the video below and know how to test your app via remote test lab tipfor a better testing experience using remote test lab, choose a device from a location near you you're done! congratulations! you have successfully achieved the goal of this code lab now, you can implement flex mode in your app by yourself! if you're having trouble, you may download this file flex mode complete code 9 07 mb to learn more about developing apps for galaxy foldable devices, visit www developer samsung com/galaxy-z
Learn Code Lab
codelabconfigure an app to enable copy and paste in multi-window objective learn how to implement copy and paste on a note-taking app when in multi-window mode overview in galaxy fold and it's latest versions, the advantage of its larger display is to split its screen and simultaneously use up to three apps in multi-window mode, you can split the screen with one window being the main focus, and the other two windows off to the side all three windows are active, not just the largest one you can multitask in either landscape or portrait mode, giving you even more flexibility when using multi-window, copy & paste is one of the useful features when multitasking copy and paste is a common feature used by many, to duplicate an object and place it in a desired location to provide users with better multitasking experience on samsung's foldable devices, developers need to optimize their apps to work on multi-window mode 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! multi-window copy & paste sample code 19 48 mb start your project open android studio and click open an existing project locate the downloaded android project simplenotes_copypaste from the directory and click ok make the app resizable to ensure that the app works in multi-window mode, you need to add an attribute in the manifest’s <activity> element if you set android resizeableactivity to true, the activity can be launched in multi-window, pop-up view and adapt different screen size android resizeableactivity= "true" noteif this attribute is set to true, the activity can be launched in split-screen and free-form modes otherwise, it will disable multi-window display remember to handle the changes required to fit your ux in small windows when in multi-window mode for this code lab, you do not need to worry about the ux as it is already handled get a reference to clipboardmanager class clipboardmanager provides methods to get and set the current primary clipboard data expressed as a clipdata object, which defines the protocol for data exchange between applications in newnote kt, get a reference to clipboardmanager class by invoking getsystemservice clipboard_service val clipboard = getsystemservice context clipboard_service as clipboardmanager complete the copy operation now, create a new clipdata of simple text using newplaintext of clipboardmanager and pass it on setprimaryclip to complete the copy operation val clip clipdata = clipdata newplaintext "simple text", textdata clipboard setprimaryclip clip get the text data from the clipboard return the clipdata by getting the primaryclip data from the clipboard from the primaryclip, acquire the item using getitemat 0 val itemtext = clipboard primaryclip? getitemat 0 ? text run the app after building the apk, you can run the optimized app and test it by copying and pasting texts between apps when in multi-window mode 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 you're done! congratulations! you have successfully achieved the goal of this code lab now, you can implement multi-window features such as copy and paste in your app by yourself! if you're having trouble, you may download this file multi-window copy & paste complete code 19 53 mb to learn more about developing apps for galaxy foldable devices, visit www developer samsung com/galaxy-z
Learn Code Lab
codelabimplement multi-window picture-in-picture on a video player objective learn how to implement multi-window picture-in-picture pip feature on a video player app for a seamless viewing experience on foldable devices overview android allows activities of apps to launch in a small window called picture-in-picture pip since android 8 0 it is a type of multi-window mode primarily used for video playback pip allows the user to continue watching in a small window pinned to a corner of the screen while browsing content on the main screen or navigating between apps 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 z fold4 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! pip video player sample code 13 30 mb start your project after downloading the sample project files, follow the steps below to open your project in android studio, click open locate the downloaded android project videoplayer_challenge from the directory and click ok configure android manifest to support pip notetake a look and check the files of your project before starting to code you can implement picture-in-picture in your app by configuring the manifest file and calling the enterpictureinpicturemode method moreover, you need to consider that the multi-window and app continuity features work correctly in pip mode to prevent the activity from restarting, handle the layout configuration change for mainactivity in the androidmanifest xml file this will ensure that it will not restart when there are layout changes from pip mode to full screen and vice versa android configchanges="screensize|smallestscreensize|screenlayout|orientation" picture-in-picture is not supported by default in android apps set android supportspictureinpicture to true in the manifest file android supportspictureinpicture="true" switch your video player to pip mode you want to trigger pip mode in your video player app when the user taps the home button to implement pip mode, go to java > com xyz codelab and make the following changes to the mainactivity kt file override fun onuserleavehint { enterpipmode } noteenterpipmode is a user-defined method you can view its full implementation in the provided sample code call enterpictureinpicturemode method in enterpipmode , you need to call enterpictureinpicturemode pictureinpictureparams method with params set in the previous lines val pictureinpictureparams = pictureinpictureparams builder setaspectratio rational build enterpictureinpicturemode pictureinpictureparams run the app after building the apk, you can now run the video player app, enhanced with a pip mode test it by playing a video while browsing the main screen or navigating between apps in multi-window mode 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 you're done! congratulations! you have successfully achieved the goal of this code lab now, you can implement multi-window picture-in-picture on a video player app for foldable devices by yourself! if you're having trouble, you may download this file pip video player complete code 13 19 mb to learn more about developing apps for galaxy foldable devices, visit developer samsung com/galaxy-z
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
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
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
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.