Simple Asset Tracking
This example provides step by step guidance on:
-
Initializing Configurations with Default Values: Learn how to set up the SDK with default configuration settings, ensuring a straightforward integration process.
-
Creating and Binding a Simple Asset: Discover how to create and bind an asset within your application, enabling you to associate assets with your tracking system.
-
Starting Tracking and Uploading Location Data with Default Values: Gain insights into how to initiate tracking and the automatic uploading of location data using default parameters, simplifying the process of monitoring asset locations.
For all code examples, refer to Asset Tracking Android Code Examples
activity_simple_tracking.xml view source
SimpleTrackingExample view source
Upon executing the code example provided above, your app's appearance will resemble the following snippet:
![documentation image](/docs/live-tracking/android-tracking/simple-asset-tracking.webp)
Code Highlights
The above code snippet is for an Android activity that demonstrates how to start tracking an asset using the Asset Tracking SDK. The activity has the following main steps:
-
Initialize the Asset Tracking SDK.
-
Create an asset.
-
Bind the asset to the device.
-
Check for location permissions and start tracking.
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, 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 to the device, the activity calls the bindAsset() method with the asset ID.
-
To check for location permissions and start tracking, the activity calls the checkPermissionsAndStartTracking() method. This method first checks if all location permissions are granted. If they are, the method starts tracking the asset. If they are not granted, the method shows a dialog to the user asking them to grant the permissions.
The code snippet also includes a few helper functions:
-
showLocationServiceOffDialog(): This function shows a dialog to the user if location services are disabled.
-
startTracking(): This function starts tracking and uploading the location data of the asset.