Skip to main content

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.
This page assumes you already have a Desmo account and at least one publishable key that starts with 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 your AndroidManifest.xml:
On Android 13+, you also need notification permission for the background tracking notification:
On Android 6.0+ you must also request these at runtime. Later on this page we’ll show how to ask for the permissions using the helpers exposed by the SDK.

1. Install the SDK (JitPack)

The Android SDK is distributed via JitPack from the GitHub repo kubocreate/desmo-android-sdk.

1.1 Add the JitPack repository

In your app project (not the SDK repo), open the root settings.gradle.kts and make sure the dependencyResolutionManagement block includes JitPack:
If you use Groovy and have settings.gradle:
If your project still uses a top-level 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 module build.gradle (usually app/build.gradle):
  1. Remove any old module dependency, for example:
  2. Add the JitPack dependency:
If you use Kotlin DSL for your app module, the equivalent is:
Here 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

Call Desmo.setup once at app startup, usually in your custom Application class.
Then register your Application class in AndroidManifest.xml:
  • apiKey: your publishable Desmo API key (starts with pk_).
  • environment:
    • DesmoEnvironment.SANDBOX – Desmo sandbox environment.
    • DesmoEnvironment.LIVE – Desmo production environment.
If 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. 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) : Boolean
  • Desmo.getMissingPermissions(context) : List<String>
Example with an Activity:
Call 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:
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 structured Address model for delivery locations:
Use structured addresses when possible — they provide better location context for delivery insights.

6. Start a delivery session

Call this when you begin recording a delivery. The SDK uses a crash-safe DesmoResult pattern that guarantees errors will never crash your app.

Required parameters

Optional parameters

Full example with all parameters

Behind the scenes, the SDK:
  • 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:
When you stop the session, the SDK:
  • 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-safe DesmoResult 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 call startSession(), the SDK automatically:
  1. Starts a foreground service to keep the app alive
  2. Shows a notification (required by Android) indicating tracking is active
  3. Continues collecting location and sensor data even when the screen is off
When you call 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, call configureForegroundService() after setup:
For full control, you can provide your own Notification object:
If you provide a custom notification, you must create the notification channel yourself before starting a session.

Next steps

From here: