Sessions¶
Part of the Human Scoring use case.
A session is the stretch of interaction a classification
is about. The SDK starts one at init. Tell the SDK when a session ends in a way only your app
knows about — a logout or an account switch — so that one user's interaction is never counted toward
the next user's classification. It is not the
ad session that DEA opens for one ad in the
Ads use case.
When to use it¶
- The user logs out
- The user switches accounts
- You need the current session id, for example to include in a support request
Prerequisites¶
- The SDK is installed and initialized. See the Quick Start.
Usage¶
Start a new session¶
reset() ends the current session and starts a new one with a new id. Evidence collected before
the reset does not count toward the new session's classification. Consent is not affected, and a
model the SDK downloaded stays in use.
Read the current session¶
import ai.dea.sdk.DeaSdk
import android.util.Log
val info = DeaSdk.instance!!.sessionInfo
Log.d("MyApp", info.session) // current session id, a UUID
Log.d("MyApp", info.sdk.version) // SDK version
Log.d("MyApp", "${info.device.surface}") // current screen size, in dp
Log.d("MyApp", "${info.device.rotation}") // 0, 90, 180 or 270
Log.d("MyApp", "${info.device.sensorRate} Hz") // 0 until motion data arrives
sessionInfo is a quick read. The device information stays current when the screen rotates or the
window is resized.
Shut the SDK down¶
dispose() stops capture and releases the SDK. Anything not yet processed is dropped. After
dispose(), DeaSdk.instance is null and DeaSdk.init can start a new instance.
Most apps never call dispose(): the SDK lives as long as the app process. Do not call it from an
Activity.onDestroy(), which runs on every rotation.
Examples¶
Reset on logout¶
import ai.dea.sdk.DeaSdk
import android.app.Activity
import android.content.Intent
fun logout(activity: Activity) {
authService.signOut()
DeaSdk.instance?.reset()
activity.startActivity(
Intent(activity, LoginActivity::class.java)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK),
)
}
API¶
| Member | Returns | Description |
|---|---|---|
reset() |
Unit |
Ends the session and starts a new one |
sessionInfo |
SessionInfo |
Session id, device and SDK version |
dispose() |
Unit |
Stops capture and releases the SDK |