Android SDK reference

Everything in strait-sdk-android 0.10.7, in one place.

On this page 7
  1. Requirements
  2. StraitConfig
  3. StraitClient
  4. LinkEvent
  5. Custom HTTP
  6. User consent (opt-out)
  7. How installs are matched

Requirements

The SDK is plain Kotlin, compiled with Kotlin 1.9.24 to Java 17 bytecode, so build your app with JDK 17 or newer (Android Gradle Plugin 8 already needs it). At runtime it uses the Kotlin standard library and org.json, which ships with Android.

StraitConfig

Parameter Type Notes
publishableKey String Required. st_pub_live_…. Never the secret key
endpoint String Required. Your link domain, https://<handle>.strait.link
device () -> DeviceFields Required. Screen width (portraitScreenWidth), pixel ratio, language, time zone
storage KeyValueStore Persists the once-per-install flag and unsent reports. Defaults to memory only
installReferrer () -> String? Blocking read of the Play Install Referrer. Called off the main thread
appVersion () -> String? Your app's versionName ({ packageManager.getPackageInfo(packageName, 0).versionName }), sent with each open and install report (with the SDK's own version) so support can see which build opened a link
installTime () -> Long? firstInstallTime from PackageManager. A reinstall from a link runs the deferred check again, even after Auto Backup restores the app's prefs. An app update doesn't
executor Executor Where network work and listeners run. Pass a background executor
linkHosts List<String> Extra hosts that serve your links
transport HttpTransport Defaults to HttpURLConnection

StraitClient

Method What it does
start(initialUrl) Handles the launch URL (or null) and runs the deferred check once per install
handleUrl(url) A link arrived while the app was running (onNewIntent)
onLink { e -> } / onLinkStart { s -> } Link events (replayed to late subscribers) and the "resolving" signal. Both return an unsubscribe function
onAppState(state) ACTIVE, INACTIVE or BACKGROUND, for app-state labels and retries
trackEvent(name, value, currency, linkId, clickId, eventId) Blocking. true when accepted. eventId is your order id, counted once; left out, the SDK makes one. An event it can't send (offline, server busy) is kept and sent later
checkDeferred() Re-runs the deferred check (debugging). Never records an install
pendingOpenReports() / flushOpenReports() Count, or send now, the open reports and events saved while offline or while the server was busy
setEnabled(enabled) / isEnabled() Opt-out switch for consent flows (see below). Kept across launches; default on
setUserId(id) Your own user id for later events' app.event webhooks (userId); null on sign-out. Memory only; emails and phone numbers are hashed on the device (how)
stop() Stops listening

LinkEvent

Field Meaning
id This open's id (not the link's)
kind direct or deferred
route app_link, custom_scheme, install_referrer or fingerprint
appState closed, background or foreground
matched, reason When matched is false: not_found, expired, password_protected, no_match, network, invalid_url
rawUrl The URL the OS gave the app
url, path, params The destination to navigate to
linkId The id of the Strait link
ms, at Resolve time in milliseconds, arrival time (epoch milliseconds)

Custom HTTP

To use OkHttp, implement HttpTransport: throw on network failure and return every HTTP status as an HttpResponse.

If your app asks for consent first (for example under India's DPDP Act or a GDPR consent flow in the EU), call links.setEnabled(false) until the person agrees: Strait then sends no open reports or events, does no install matching, and deletes reports waiting on the device. The choice is kept across launches; setEnabled(true) turns it back on and isEnabled() reads it. A Strait short link still opens the right screen: it is looked up without recording a tap, an open or a tap id. Whether you need consent, and for what, is a question for your own legal advice.

How installs are matched

When someone without your app taps a link, we send them to Google Play with the link in the install referrer. On first open the SDK reads it and resolves the exact link and tap. No guessing. See Deferred deep linking.