Sentiance
This document refers to deprecated parts of the platform and has been left intact to help customers with legacy integrations. In order to access the latest platform features and documentation, please go to https://docs.sentiance.com.
The Sentiance class is the main entry point for interacting with the SDK. This class is a singleton, therefore you can obtain an instance as follows:
With the exception of the following 4 methods, all other methods in this class will throw an exception when invoked before SDK initialization is complete (seeinit()
).
init()
reset(ResetCallback)
getInitState()
getVersion()
Sentiance API
addUserMetadataField()
addUserMetadataField()
Adds a user specific metadata field.
Parameters | |
---|---|
label | Metadata label to add. |
value | Metadata value. |
addUserMetadataFields()
addUserMetadataFields()
Adds multiple user specific metadata fields.
Parameters | |
---|---|
metadata | The metadata fields. |
addTripMetadata()
addTripMetadata()
Adds metadata while an external trip is ongoing. This method can be called multiple times during a trip.
This method returns false if there is no ongoing external trip or
null
metadata is passed.
Parameters | |
---|---|
metadata | A map of metadata pertaining to the ongoing trip, which will be saved along with the trip data. |
disableBatteryOptimization()
disableBatteryOptimization()
Generates a system dialog asking the user to allow disabling battery optimization for the app.
Learn more about disabling battery optimization here.
getDiskQuotaLimit()
getDiskQuotaLimit()
Returns the SDK's disk quota limit in bytes.
getDiskQuotaUsage()
getDiskQuotaUsage()
Returns the SDK's disk quota usage in bytes.
getInitState()
getInitState()
Returns the initialization state of the Sentiance SDK.
getInstance()
getInstance()
Returns an instance of the
Sentiance
class.This method will call
Context.getApplicationContext()
on the passed context to prevent memory leaks when passing an Activity context.
Parameters | |
---|---|
context | A |
getMobileQuotaLimit()
getMobileQuotaLimit()
Returns the SDK's mobile data quota limit in bytes.
getMobileQuotaUsage()
getMobileQuotaUsage()
Returns the SDK's mobile data quota usage in bytes.
getSdkStatus()
getSdkStatus()
Returns an
SdkStatus
object representing the state of the SDK.
getUserActivity()
getUserActivity()
Returns a
UserActivity
object representing the currently detected user's activity.
getUserAccessToken()
getUserAccessToken()
Returns the user's API access token as a
Token
object via the specified callback.For more information regarding failure, see
TokenResultCallback.onFailure()
.
Parameters | |
---|---|
callback | A callback to handle the token result. Note that the SDK holds a weak reference to this callback in order to prevent component leaks. Make sure you have a strong reference to it in order to guarantee its execution. |
getUserId()
getUserId()
Returns the Sentiance user ID, or
null
if authentication has not yet succeeded.
getVersion()
getVersion()
Returns the SDK version as a String.
getWiFiQuotaLimit()
getWiFiQuotaLimit()
Returns the SDK's WiFi quota limit in bytes.
getWiFiQuotaUsage()
getWiFiQuotaUsage()
Returns the SDK's WiFi quota usage in bytes.
init()
init()
Initializes the Sentiance Sdk.
This method constructs internal SDK components and prepares the SDK for handling app and system requests. If a Sentiance user does not yet exist on the device, this method triggers user creation on the Sentiance Platform, which requires internet connectivity.
During the lifetime of the app process, calling this method again after a successful initialization is not allowed. Doing so is regarded as an error and therefore throws an
SdkException
at runtime. To reinitialize the SDK with a different configuration or to create a new Sentiance user, first callreset(ResetCallback)
.All methods in this class (except this method,
reset(ResetCallback)
,getInitState()
andgetVersion()
) will throw anSdkException
when called before initialization has completed.
Parameters | |
---|---|
sdkConfig | An |
initCallback | An |
invokeDummyCrash()
invokeDummyCrash()
Invokes a dummy crash event. Use this method to test your crash callback integration.
Calling this method will invoke the
onCrash(long, Location)
method of yourCrashCallback
implementation, set viasetCrashCallback(CrashCallback)
.Note that this method is intended for testing your integration, and will only run on debug versions of your app (i.e. when the
android:debuggable
manifest flag is set totrue
).
isCrashDetectionSupported()
isCrashDetectionSupported()
Checks if crash detection is supported on the device for the specified trip type.
The result depends on multiple criteria, such as if crash detection is enabled for your app, and if the necessary sensors are present on the device.
Parameters | |
---|---|
tripType | A |
isTripOngoing()
isTripOngoing()
Indicates whether a trip is in progress.
Parameters | |
---|---|
tripType | A |
removeUserMetadataField()
removeUserMetadataField()
Removes a user specific metadata field.
Parameters | |
---|---|
label | Metadata to remove. |
reset()
reset()
The reset functionality is intended for removing all data in the device to handle a case such as a user logging out from an app or user requesting data deletion in the local app. It should not be used to reset the internal state of the SDK.
Resets the Sentiance SDK.
Calling this method results in stopping of all SDK operations and deleting all SDK user data from the device. Additionally, the SDK will be uninitialized, allowing reinitialization and new Sentiance user creation.
The reset operation may take a while, in which case the SDK's initialization state will be set to
InitState.RESETTING
until it's complete. Calling any other SDK method during this time will either be ignored or return a default value. While resetting, make sure your app is in the foreground to prevent process termination (i.e. an activity is open, or a foreground service is running).Note that calling this method during intermediate initialization states (i.e.
INIT_IN_PROGRESS
andRESETTING
) will fail.
Parameters | |
---|---|
callback | A |
setCrashCallback()
setCrashCallback()
This method is deprecated. Use setVehicleCrashListener(VehicleCrashListener)
instead.
Sets a callback that is invoked when a vehicle crash is detected.
Parameters | |
---|---|
callback | A |
setTripProfileListener()
setTripProfileListener()
Deprecated
This method was deprecated in v4.21.0, as part of the Trip Profiling feature deprecation.
Sets a listener that is invoked after a completed trip has been profiled. This feature must first be enabled for your app since it is not enabled by default.
�Note that profiling is only done on
VehicleMode.VEHICLE
transports of a trip. The listener is invoked only if the profiled trip contains aTransportSegment
of typeVehicleMode.VEHICLE
.
Parameters | |
---|---|
tripProfileListener | A |
setTripTimeoutListener()
setTripTimeoutListener()
Sets a listener that is invoked when a trip times out. This method is relevant only when triggered trips are enabled via
setTriggeredTripsEnabled(boolean)
on theSdkConfig.Builder
object. Trips do not time out otherwise.To learn more about trip timeouts, see controlled detections.
Parameters | |
---|---|
listener | A |
setUserActivityListener()
setUserActivityListener()
Sets a listener that is invoked when a new user activity is detected. After calling this method, the current user activity will be immediately delivered to the listener.
Parameters | |
---|---|
listener | A |
setVehicleCrashListener()
setVehicleCrashListener()
Sets a listener that is invoked when a vehicle crash is detected.
Parameters | |
---|---|
listener | A |
start()
start()
Starts the SDK detections.
When this process has finished,
OnStartFinishedHandler.onStartFinished(SdkStatus)
will be called. This does not necessarily mean that the SDK is actually performing detections. You may use theSdkStatus
passed to theonStartFinished(SdkStatus)
method to determine why.To automatically stop detections, call the
start(Date, OnStartFinishedHandler)
method instead. You do not need to callstop()
beforehand as all start calls override each other.
Parameters | |
---|---|
handler | A |
start()
start()
Starts the SDK detections.
This method has the same behaviour as
start(OnStartFinishedHandler)
except an absolute date is passed to automatically stop the SDK some time in the future. A typical use-case is when the app provides a free trial period for its users after which the SDK should stop running.To cancel the auto-stop functionality, you can call this method with a null stopDate or just call
start(OnStartFinishedHandler)
. You do not need to callstop()
beforehand as all start calls override each other.
Parameters | |
---|---|
stopDate | An absolute date at which the SDK is stopped. If the date is in the past, the SDK will stop immediately. |
handler | A |
startTrip()
startTrip()
Starts an external trip.
To learn more about external trips, see controlled detections.
Parameters | |
---|---|
metadata | A map of metadata pertaining to the newly started trip, which will be saved along with the trip data. |
transportModeHint | A |
callback | A |
stop()
stop()
Stops the SDK detections.
stopTrip()
stopTrip()
Stops the currently ongoing external trip (started by calling
starTrip()
).To learn more about external trips, see controlled detections.
Parameters | |
---|---|
callback | A |
submitDetections()
submitDetections()
Submits the detections to the Sentiance API. This will bypass any network quota limitation.
�A typical use case of this method would be when the enclosing app determines (via
getDiskQuotaUsage()
orSdkStatus.diskQuotaStatus
) that there are too many detections on disk that have not yet been submitted.
Parameters | |
---|---|
callback | A |
updateSdkNotification()
updateSdkNotification()
Replaces the notification set in
SdkConfig.Builder
. After calling this method, any notification shown by the SDK will be updated.�Note that this change is valid only during the process's lifetime. After the app process restarts, the SDK will default back to the notification set in
SdkConfig.Builder
.
Parameters | |
---|---|
notification | A |
updateTripProfileConfig()
updateTripProfileConfig()
Updates the
TripProfileConfig
. Configuration fields can be updated individually without the need to set all the other fields. Updating the configuration remains persistent so it doesn't have to be set after every SDK init. If the app passes a null configuration field, that field will be set to SDK default. All configuration fields will be set to SDK default if the app resets the SDK.
Parameters | |
---|---|
tripProfileConfig | trip profile configuration. |
Last updated