Asset profile Operations
This example demonstrates:
-
Creating an Asset: Learn how to generate a new asset within your application, enabling the introduction of new assets into your tracking system.
-
Binding an Existing Asset ID to the Current Device: Discover the process of associating an existing asset ID with the device you're currently using, facilitating tracking and management of that asset.
-
Updating the Current Asset Profile: Gain insights into how to modify the profile of an asset, ensuring that the asset's information remains accurate and up-to-date.
-
Retrieving Asset Details for the Bound Asset ID: Learn how to access and retrieve detailed information about an asset that has been successfully bound to the current device, enabling comprehensive asset management.
For all code examples, refer to Asset Tracking Android Code Examples
activity_asset_profile_operation.xml view source
AssetProfileOperations view source
Upon executing the code example provided above, your app's appearance will resemble the following snippet:
Code Highlights
The above code snippet is for an Android activity that demonstrates how to perform asset profile operations using the Asset Tracking SDK. The activity has the following main functionalities:
-
Initialize the Asset Tracking SDK.
-
Create an asset profile.
-
Bind the asset profile to the device.
-
Update the asset profile.
-
Get the asset profile details.
The following is a description of each step:
-
To initialize the Asset Tracking SDK, the activity calls the initialize() method with your API key.
-
To create an asset profile, the activity creates an AssetProfile object and sets its properties. The AssetProfile object specifies the asset's custom ID, name, description, and attributes.
-
To bind the asset profile to the device, the activity calls the bindAsset() method with the asset ID.
-
To update the asset profile, the activity creates a new AssetProfile object with the updated properties and calls the updateAssetInfo() method.
-
To get the asset profile details, the activity calls the getAssetInfo() method.
The code snippet also includes a few helper functions:
-
createNewAsset(): This function creates a new asset and returns the asset ID.
-
bindAsset(): This function binds an asset profile to the device.
-
updateAssetInfo(): This function updates an asset profile.
-
getAssetInfo(): This function gets the details of an asset profile.