com.trevosdk:trevosdk-android runs experiments and records events in Android apps, assigning
the same variant the web SDK does for the same user. Kotlin, no dependencies beyond the Kotlin
standard library, Android 5.0 (API 21) and later. Kotlin projects need Kotlin 2.0 or later; Java
projects work as they are.
INTERNET permission, which merges into your manifest.
Create the client
Use a Mobile key (tsk_live_…). Keep it in your build configuration, for example a
buildConfigField, and create one client in Application.onCreate:
versionName, so minAppVersion gating and the version on every
event work with no setup. Every method is safe to call from any thread. Create it in the main
process only: a second process would share its files.
Read a variant
getVariant is synchronous and safe on the main thread. It returns control until stored
state and the first config fetch have loaded, so wait for ready() (a suspend function) or
whenReady { } before showing experiment UI:
trackExposure = false to read without
recording one. onChange calls a listener on the main thread whenever config or identity
changes; keep the returned TrevoSubscription and cancel() it when the screen goes away.
Parameters
A parameter lets later experiments change a value with no release:String, Boolean, Int, Long and Double. A value of another
type, or a number that isn’t whole for Int or Long, serves the default.
A String parameter can carry text per language:
pass your app’s own translation as the default, and if users can pick the app’s language, call
trevo.setLocale("pt-BR") when they do. Without it the SDK reads the app’s configured locale.
Track events and identify users
flush().
See Mobile experiments for how experiments ramp on mobile, how
the SDK survives a lost network, and the Google Play data safety answers.