Skip to main content

Android SDK Functions

Complete reference for the Told Android SDK API.

INIT

Initialize the SDK. Must be called before any other function, typically in your Application.onCreate().

Told.init(
configuration = ToldConfiguration(
sourceId = "YOUR_SOURCE_ID",
applicationId = applicationContext.packageName,
appVersion = "${BuildConfig.VERSION_NAME}#${BuildConfig.VERSION_CODE}",
environment = ToldEnvironment.Production,
preview = false,
),
applicationContext = applicationContext,
)
ParameterTypeDescription
sourceIdStringYour source ID from Told
applicationIdStringYour app's package name
appVersionStringYour app version
environmentToldEnvironment.Production or .Development
previewBooleanEnable preview mode

IDENTIFY

Update the current user's information. Call this when the user logs in or when their profile changes.

Told.identify(properties: Map<String, Any>)

Example:

Told.identify(mapOf(
"id" to "user_123",
"name" to "Jane Doe",
"email" to "[email protected]"
))

SET LANGUAGE

Override automatic language detection:

Told.identify(mapOf("language" to "en"))

TRACK EVENT

Send a custom event for triggering surveys:

Told.trackEvent(eventName: String, properties: Map<String, Any> = emptyMap())

Example:

Told.trackEvent("purchase_completed", mapOf("amount" to 49.99))

REGISTER NAV CONTROLLER

Register a Jetpack Navigation controller to automatically track screen changes:

val navController: NavHostController = rememberNavController()
LaunchedEffect(key1 = navController) {
Told.registerNavController(navController = navController)
}

The destination name sent to Told is the fully qualified name of your destination (e.g., com.myapp.MyDestination). This name must match the trigger configuration in the Told dashboard.


REGISTER ACTIVITY CALLBACK

For activity-based navigation (no NavController), register to listen for activity changes:

Told.registerActivityCallback()

Call this once during your application's lifecycle. If you use NavController, prefer registerNavController instead.


UNREGISTER ACTIVITY CALLBACK

Manually unregister the activity callback if needed:

Told.unregisterActivityCallback()

START

Manually start a specific survey by ID:

Told.start(surveyId: String, withDelay: Duration = 0.seconds)

RESET

Reset the user to anonymous state. Call this when the user logs out:

Told.reset(newConfiguration: ToldConfiguration? = null)

Optionally pass a new configuration if you need to change the source ID after reset.


DEBUG WIDGET

Log diagnostic information about your source and surveys to Logcat:

Told.debugWidget()