Android (Kotlin)
Android Functions
Initializer
devId
: your developer IDreferenceId
: the reference_id for the end usercontext
: the [android.app.Activity] context which you initialise this class inreferenceId
: the user ID associated to the user in your systemcompletion
: a completion function depicting if the initialisation was successful or not
Connection Setup
initConnection
Initialise a connection with Terra's backend for the device
token
: An authentication token that should be generated from the backend.callback
: A function called when the initialization is complete with a boolean indicating success.
getUserId
A synchronous function that returns the current device's Terra user ID.
Returns
String?
: The user ID. If none exists, returnsnull
.
disconnect
Disconnects from a connection.
type
: Enum representing the connection type to disconnect.
Device Connection Management
startDeviceScan
Starts a device scan and allows the user to connect to a device.
type
: The connection type you're trying to connect to.useCache
: Iftrue
, uses previously connected devices (default isfalse
).showWidgetIfCacheNotFound
: if true, shows the connection widget if cached device is not foundcallback
: Called with a boolean after the connection is established.deviceCallback
: callback function called with [Device] object whenever a device is found
getConnectedDevices
Returns a set of devices that are currently connected
Returns
Set<ConnectedDevice>
, the set of currently connected devices
Data Streaming
startRealtime
Starts streaming data for a given connection type.
type
: Enum representing the connection type.token
: The token used for verification to connect to Terra’s API.dataTypes
: Enum representing the data types to stream.connectionCallback
: Called when a websocket connection is either successful or not.updateHandler
: Called when new updates are available from the device.
stopRealtime
Stops streaming for a given connection type.
type
: Enum representing the connection type to stop streaming for.
Was this helpful?