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
.
Then reference this new class in the application tag of the AndroidManifest.xml
2. Initialize the SDK
In the onCreate()
method of your Application
class, call initialize()
.
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.
3. Customize the Android Notification (Optional)
When the Sentiance SDK runs in the background, it initiates a foreground service and provides a notification to Android, which is displayed to the user while the service is active.
By customizing the notification you can tailor the appearance and behavior of the notification to match the branding and user experience of your application. This allows you to provide a seamless and consistent experience to your users while the Sentiance SDK operates in the background.
Please note that customizing the notification should be done carefully to ensure that it complies with Android guidelines and user preferences. By doing so, you can enhance the overall user experience and maintain a cohesive presentation of your app and the Sentiance SDK's background functionality.
You can specify the notification that the SDK should use by passing it to the SDK initializer as an option:
If the id
that you specify here matches the ID of another notification, Android will show only one notification (the last published one). If your app has an ongoing notification of its own, you can do ID sharing to avoid redundant notifications during SDK detections.
Last updated