The purpose of this app is to demonstrate Verisoul's Android SDK integration.
To run the app a Verisoul Project ID is required. Schedule a call here to get started.
Add these lines to your settings.gradle
file.
dependencyResolutionManagement {
repositories {
...
maven { url = uri("https://us-central1-maven.pkg.dev/verisoul/android") }
}
}
Add these lines to your build.gradle
file.
dependencies {
...
implementation "ai.verisoul:android:1.0.3"
}
dependencies {
...
implementation(libs.verisoul.android)
}
Add these lines to your libs.versions.toml
file.
Under the [versions]
add:
verisoul = "1.0.3"
Under the [libraries]
add:
verisoul-android = { group = "ai.verisoul", name = "android", version.ref = "verisoul" }
Initialization should be called in overridden onCreate()
function from Application
class that should be defined in the AndroidManifest.xml
file. For example:
Application class
class SampleApplication : Application() {
override fun onCreate() {
super.onCreate()
Verisoul.init(
this,
VerisoulEnvironment.Prod, // or Sandbox
"<VERISOUL_PROJECT_ID>"
)
}
}
AndroidManifest.xml
<manifest>
<application
android:name=".SampleApplication">
...
</application>
</manifest>
When this is called Verisoul library will be initialized, initial data together with session ID will be gathered and uploaded to Verisoul backend.
Once the minimum amount of data is gathered the session ID becomes available. The session ID is needed in order to request a risk assessment from Verisoul's API. Note that session IDs are short lived and will expire after 24 hours. The application can obtain session ID by providing the callback as shown below:
Verisoul.getSessionId(
callback = object : VerisoulSessionCallback {
override fun onSuccess(sessionId: String) {
// Upload session ID to backend
}
override fun onFailure(exception: Exception) {
// Handle exception
}
}
)
In order to gather touch events and compare them to device accelerometer sensor data, the app will need to provide touch events to Verisoul. The way to achieve this is to create BaseActivity
, to override dispatchTouchEvent
function and pass the data to Verisoul like shown below.
open class BaseActivity : Activity() {
override fun dispatchTouchEvent(event: MotionEvent?): Boolean {
Verisoul.onTouchEvent(event)
return super.dispatchTouchEvent(event)
}
// Other common BaseActivity code...
}
In the application, just use BaseActivity as an Activity base class.
class MainActivity : BaseActivity() {
// Other Activity code...
}
Comprehensive documentation about Verisoul's Android SDK and API can be found at docs.verisoul.ai. Additionally, reach out to Verisoul at [email protected] for any questions or feedback.