• Optimization
  • Navigation
  • Tracking
  • Maps
  • Places

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

1<?xml version="1.0" encoding="utf-8"?>
2<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 xmlns:app="http://schemas.android.com/apk/res-auto"
4 xmlns:tools="http://schemas.android.com/tools"
5 android:layout_width="match_parent"
6 android:layout_height="match_parent"
7 android:orientation="vertical"
8 android:padding="10dp"
9 tools:context=".codeexample.AssetProfileOperations">
11 <Button
12 android:id="@+id/create_asset"
13 android:layout_width="wrap_content"
14 android:layout_height="wrap_content"
15 android:text="@string/create_asset" />
17 <Button
18 android:id="@+id/bind_asset_to_device"

AssetProfileOperations view source

1class AssetProfileOperations : AppCompatActivity() {
2 private var assetId = ""
3 private var assetName = "testName"
4 private var assetDescription = "testDescription"
5 private var assetAttributes: Map<String, String> = mapOf("attribute 1" to "test 1", "attribute 2" to "test 2")
7 private lateinit var createAssetButton: Button
8 private lateinit var bindAssetButton: Button
9 private lateinit var updateAssetButton: Button
10 private lateinit var getAssetDetailButton: Button
11 private lateinit var assetDetailView: TextView
14 override fun onCreate(savedInstanceState: Bundle?) {
15 super.onCreate(savedInstanceState)
16 setContentView(R.layout.activity_asset_profile_operation)
17 initView()

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:

  1. Initialize the Asset Tracking SDK.

  2. Create an asset profile.

  3. Bind the asset profile to the device.

  4. Update the asset profile.

  5. Get the asset profile details.

The following is a description of each step:

  1. To initialize the Asset Tracking SDK, the activity calls the initialize() method with your API key.

  2. 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.

  3. To bind the asset profile to the device, the activity calls the bindAsset() method with the asset ID.

  4. To update the asset profile, the activity creates a new AssetProfile object with the updated properties and calls the updateAssetInfo() method.

  5. 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.

Have Questions ?