What you’ll build
In this quickstart you will:- Install the Desmo Android SDK via JitPack.
- Initialize the SDK with your publishable key.
- Start and stop a delivery session from your Android app.
pk_....If you don’t have a key yet, contact your Desmo representative to have one issued for your project.
Requirements
- Android 7.0 (API 24) or later
- Android Gradle Plugin compatible with Kotlin 1.9+
- Your app is written in Kotlin (the SDK is a Kotlin library)
App permissions
To let Desmo record sessions correctly, your app should request location permissions so sessions can be tied to where the delivery happened. Add these to yourAndroidManifest.xml:
1. Install the SDK (JitPack)
The Android SDK is distributed via JitPack from the GitHub repokubocreate/desmo-android-sdk.
1.1 Add the JitPack repository
In your app project (not the SDK repo), open the rootsettings.gradle.kts and make sure the dependencyResolutionManagement block includes JitPack:
settings.gradle:
build.gradle with an allprojects { repositories { ... } } block instead of dependencyResolutionManagement, add the jitpack.io maven entry there:
1.2 Add the dependency
In your app modulebuild.gradle (usually app/build.gradle):
-
Remove any old module dependency, for example:
-
Add the JitPack dependency:
v1.0.2 is the Git tag for the SDK release on GitHub. When a new version is tagged, update this value to match.
If you previously copied any Desmo code directly into your project, or used old Maven Central coordinates or local module references, remove those and keep only the JitPack dependency to avoid duplicate classes.
2. Initialize the SDK
CallDesmo.setup once at app startup, usually in your custom Application class.
Application class in AndroidManifest.xml:
apiKey: your publishable Desmo API key (starts withpk_).environment:DesmoEnvironment.SANDBOX– Desmo sandbox environment.DesmoEnvironment.LIVE– Desmo production environment.
Desmo.setup fails (for example, if the key does not start with pk_), the SDK will log an error and Desmo.client will remain null.
Lifecycle binding (recommended)
Desmo.bindToProcessLifecycle() automatically manages sensor registration when your app moves between foreground and background. This ensures sensors are re-registered properly after Android throttles them in the background.
Without a Context (no telemetry)
There is also a setup(apiKey, environment) overload that does not take a Context. This is useful in non-Android environments, but it disables on-device telemetry. For typical courier apps you should prefer the setup(context, apiKey, environment) version so telemetry is enabled.
3. Request permissions at runtime
The SDK exposes helpers so you know which permissions are required and whether they are granted:Desmo.getRequiredPermissions() : Array<String>Desmo.hasRequiredPermissions(context) : BooleanDesmo.getMissingPermissions(context) : List<String>
Activity:
ensureDesmoPermissions() before you start a session so location is available.
Notification permission (Android 13+)
On Android 13 and later, you need to request notification permission separately for the background tracking notification:If notification permission is denied, sessions will still work when the app is in the foreground. However, background tracking won’t function without the notification.
4. Understanding session types
Every session requires a session type that indicates what the driver is doing:| SessionType | When to use |
|---|---|
SessionType.PICKUP | Driver is collecting a package from a merchant/warehouse |
SessionType.DROP | Driver is delivering a package to a customer |
SessionType.TRANSIT | Driver is traveling between stops (no specific address) |
For
PICKUP and DROP sessions, you should provide an address. For TRANSIT sessions, the address is optional.5. Understanding the Address model
The SDK provides a structuredAddress model for delivery locations:
6. Start a delivery session
Call this when you begin recording a delivery. The SDK uses a crash-safeDesmoResult pattern that guarantees errors will never crash your app.
Required parameters
| Parameter | Type | Description |
|---|---|---|
deliveryId | String | Your internal delivery/order identifier |
sessionType | SessionType | PICKUP, DROP, or TRANSIT |
Optional parameters
| Parameter | Type | Description |
|---|---|---|
address | Address? | Delivery address (required for PICKUP/DROP, optional for TRANSIT) |
externalRiderId | String? | Your system’s driver/rider ID |
startLocation | StartLocation? | Override the starting GPS position (auto-captured if not provided) |
Full example with all parameters
- Calls Desmo’s backend to create a session.
- Starts collecting telemetry on-device (when initialized with a
Context). - Starts a foreground service for background tracking.
- Begins batching telemetry to Desmo while the session is recording.
7. Stop a delivery session
Call this when the delivery is complete:- Flushes any remaining telemetry.
- Notifies the backend that the session is complete.
- Stops the background tracking service and removes the notification.
- Lets Desmo’s workers start processing PoD intelligence for that session.
8. The DesmoResult pattern
The SDK uses a crash-safeDesmoResult pattern instead of throwing exceptions. This guarantees SDK errors will never crash your app.
Always handle
onFailure gracefully. The driver’s delivery flow should continue even if the SDK encounters an error.9. Background operation
The SDK automatically keeps tracking when the app goes to background. This is critical for delivery apps where drivers put their phone in their pocket.How it works
When you callstartSession(), the SDK automatically:
- Starts a foreground service to keep the app alive
- Shows a notification (required by Android) indicating tracking is active
- Continues collecting location and sensor data even when the screen is off
stopSession(), the service stops and the notification disappears.
Default notification
By default, the notification uses a generic location icon with text:- Title: “Recording Active”
- Text: “Tracking delivery in progress”
Customizing the notification (optional)
To show your own branding, callconfigureForegroundService() after setup:
Notification object:
If you provide a custom notification, you must create the notification channel yourself before starting a session.
Next steps
From here:- Configure keys and environments in Android Auth & Environments.
- Enable logging and troubleshoot in Android Logging, Debugging & Troubleshooting.
- Revisit the Desmo Integration Overview at Integrating Desmo to see how the Android and iOS SDKs fit with your backend APIs and dashboard.