2. Initialization
Initialization sets up internal SDK components to allow the creation of a Sentiance user on the device, and perform detections in the background.
Only a limited set of SDK methods are allowed to be invoked before initializing the SDK.

1. Create an Application Class

Initialization must be done in the onCreate() method of your Application class. If you don't already have a custom application class, first create a new class that extends Application.
MyApplication.kt
import android.app.Application;
class MyApplication: Application() {
override fun onCreate() {
super.onCreate()
}
}
Then reference this new class in the application tag of the AndroidManifest.xml
<application android:name="com.example.appname.MyApplication">
<!-- Activities -->
</application>

2. Initialize the SDK

In the onCreate() method of your Application class, call initialize().
MyApplication.kt
override fun onCreate() {
super.onCreate()
val result = Sentiance.getInstance(this).initialize()
if (result.isSuccessful) {
Log.d(TAG, "Initialization succeeded");
}
}
Initialization will normally succeed, unless an unexpected error or exception is encountered. In case of failure, you can check the reason via the returned result.
if (result.isSuccessful) {
Log.d(TAG, "Initialization succeeded");
} else {
Log.e(TAG, "Intialization failed with reason ${result.failureReason!!.name}", result.throwable);
}
Custom Notification
To learn more about Initialization, see the SDK Initialization page.
Copy link
On this page
1. Create an Application Class
2. Initialize the SDK