LogoLogo
Insights
  • Introduction
  • A standard integration
  • FAQ
    • FAQ
      • Integration (FAQ)
      • Detections (FAQ)
      • Data interface (FAQ)
      • Security, Privacy and Terms of Service (FAQ)
      • Journeys and Insights (FAQ)
  • SDK
    • Getting Started
      • Android Quick Start
        • 1. Android Checklist
        • 2. Including the SDK
        • 3. Configuration
          • Sample Notification
        • 4. Initialization
        • 5. Starting Detections
        • 6. SDK Status Updates
        • 7. Permissions
        • 8. What's Next
      • iOS Quick Start
        • 1. iOS Checklist
        • 2. Installation
          • Installation with CocoaPods
          • Installation with Carthage
          • Manual Installation
        • 3. Configuration
          • Using Integration Guide
          • Manual Configuration
        • 4. Usage
        • 5. Tips and Guidelines
        • 6. What's Next
      • React Native Quick Start
        • 1. React Native Checklist
        • 2. Installation
        • 3. Configuration
        • 4. Initialization
        • 5. Usage
        • 6. What's Next
    • Appendix
      • Android
        • Android 10 Update Behavior
        • Android Battery Optimization
        • External SDK Dependencies
        • Manifest Permissions
        • Notification Management
      • iOS
        • App Store Privacy Section
        • App Store Release
        • iOS 13 permission changes
        • M1 Simulator Support
        • Swift Support
      • Control Sending Data
      • Controlled Detections
        • Automatic Detections
        • Automatic Detections with Forced Trips
        • Controlled Trips Only
        • Checking Trip Status
      • Custom User Metadata
      • Detecting Vehicle Crashes
      • Migration Guide
        • Android
        • iOS
      • React Native
      • SDK Initialization
      • User Credentials
      • User Linking
      • Xamarin
    • API Reference
      • Android
        • VehicleCrashDetection
          • VehicleCrashEvent
          • VehicleCrashListener
          • CrashCallback
        • InitState
        • MetaUserLinker
        • MetaUserLinkerAsync
        • MetaUserLinkerCallback
        • OnInitCallback
          • InitIssue
        • OnSdkStatusUpdateHandler
        • OnStartFinishedHandler
        • PoiAddress
        • PoiLocation
        • PointOfInterest
        • PoiPlace
        • ResetCallback
          • ResetFailureReason
        • SdkConfig
          • Builder
        • SdkException
        • SdkStatus
          • LocationSetting
          • Quota Status
          • StartStatus
        • Sentiance
        • SubmitDetectionsCallback
        • StationaryInfo
        • Token
        • TokenResultCallback
        • Trip
          • StartTripCallback
          • StopTripCallback
          • TransportMode
          • TripTimeoutListener
          • TripType
        • TripInfo
        • TripProfile
          • HardEvent
          • TransportSegment
          • VehicleMode
        • TripProfileConfig
          • Builder
        • TripProfileListener
        • UserActivity
        • UserActivityListener
        • UserActivityType
      • iOS
        • MetaUserLinker
        • SENTSDK
          • SENTSDKStatus
          • SENTPublicDefinitions
        • SENTConfig
        • SENTTripProcessingTripProfile
          • SENTTripProcessingTransportSegment
          • SENTTripProcessingHardEvent
          • SENTTripProcessingVehicleMode
        • SENTVehicleCrashEvent
      • React Native
    • Battery Optimization
    • How To
      • Check the Location Permissions
    • Troubleshooting
      • Android
      • iOS
        • Bundle format unrecognized, invalid, or unsuitable
        • Error: Undefined symbols for architecture arm64
    • Changelog
      • Android
      • iOS
  • Important topics
    • Authentication and Authorization
    • User linking
    • PlayStore Location Access Review
    • Privacy Report & Dashboard
    • Vehicle Crash Detection
  • Library
    • Events
    • Moments
    • Segments
    • Glossary
  • Backend
    • GraphQL
    • REST API Reference
      • Error Codes (REST API)
    • Offloads
    • Data Reference
      • Data Reference A-B
      • Data Reference C-G
      • Data Reference H-L
      • Data Reference M-P
      • Data Reference Q-T
      • Data Reference U-Z
  • Data Explorer
    • Data Explorer
      • Global (EU)
      • US
      • Australia
  • Guide
    • Firehose
    • Verifying your integration
    • SDK Standard License
    • Journeys License
    • Journeys Application
    • Journeys Privacy Policy
    • Technical & Organizational Measures
Powered by GitBook
On this page
  • Sentiance API
  • addUserMetadataField()
  • addUserMetadataFields()
  • addTripMetadata()
  • disableBatteryOptimization()
  • getDiskQuotaLimit()
  • getDiskQuotaUsage()
  • getInitState()
  • getInstance()
  • getMobileQuotaLimit()
  • getMobileQuotaUsage()
  • getSdkStatus()
  • getUserActivity()
  • getUserAccessToken()
  • getUserId()
  • getVersion()
  • getWiFiQuotaLimit()
  • getWiFiQuotaUsage()
  • init()
  • invokeDummyCrash()
  • isCrashDetectionSupported()
  • isTripOngoing()
  • removeUserMetadataField()
  • reset()
  • setCrashCallback()
  • setTripProfileListener()
  • setTripTimeoutListener()
  • setUserActivityListener()
  • setVehicleCrashListener()
  • start()
  • start()
  • startTrip()
  • stop()
  • stopTrip()
  • submitDetections()
  • updateSdkNotification()
  • updateTripProfileConfig()
  1. SDK
  2. API Reference
  3. Android

Sentiance

PreviousStartStatusNextSubmitDetectionsCallback

Last updated 1 year ago

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:

Sentiance sentianceSDK = Sentiance.getInstance(context);

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 (see).

  • init()

  • reset(ResetCallback)

  • getInitState()

  • getVersion()

Sentiance API

addUserMetadataField()

void addUserMetadataField(String label, String value)

Adds a user specific metadata field.

Parameters

label

Metadata label to add.

value

Metadata value.

addUserMetadataFields()

void addUserMetadataFields(Map<String, String> metadata)

Adds multiple user specific metadata fields.

Parameters

metadata

The metadata fields.

addTripMetadata()

boolean addTripMetadata(Map<String, String> metadata)

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()

void disableBatteryOptimization()

Generates a system dialog asking the user to allow disabling battery optimization for the app.

Learn more about disabling battery optimization here.

getDiskQuotaLimit()

long getDiskQuotaLimit()

Returns the SDK's disk quota limit in bytes.

getDiskQuotaUsage()

long getDiskQuotaUsage()

Returns the SDK's disk quota usage in bytes.

getInitState()

InitState getInitState()

Returns the initialization state of the Sentiance SDK.

getInstance()

static Sentiance getInstance(Context context)

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

getMobileQuotaLimit()

long getMobileQuotaLimit()

Returns the SDK's mobile data quota limit in bytes.

getMobileQuotaUsage()

long getMobileQuotaUsage()

Returns the SDK's mobile data quota usage in bytes.

getSdkStatus()

SdkStatus getSdkStatus()

Returns an SdkStatus object representing the state of the SDK.

getUserActivity()

UserActivity getUserActivity()

Returns a UserActivity object representing the currently detected user's activity.

getUserAccessToken()

void getUserAccessToken(TokenResultCallback callback)

Returns the user's API access token as a Token object via the specified callback.

Parameters

callback

getUserId()

@Nullable String getUserId()

Returns the Sentiance user ID, or null if authentication has not yet succeeded.

getVersion()

String getVersion()

Returns the SDK version as a String.

getWiFiQuotaLimit()

long getWiFiQuotaLimit()

Returns the SDK's WiFi quota limit in bytes.

getWiFiQuotaUsage()

long getWiFiQuotaUsage()

Returns the SDK's WiFi quota usage in bytes.

init()

void init(SdkConfig sdkConfig, final OnInitCallback initCallback)

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 call reset(ResetCallback).

Parameters

sdkConfig

initCallback

invokeDummyCrash()

void invokeDummyCrash()

Invokes a dummy crash event. Use this method to test your crash callback integration.

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 to true).

isCrashDetectionSupported()

boolean isCrashDetectionSupported(TripType tripType)

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

isTripOngoing()

boolean isTripOngoing(TripType tripType)

Indicates whether a trip is in progress.

Parameters

tripType

removeUserMetadataField()

void removeUserMetadataField(String label)

Removes a user specific metadata field.

Parameters

label

Metadata to remove.

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.

void reset(@Nullable ResetCallback callback)

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 and RESETTING) will fail.

Parameters

callback

setCrashCallback()

void setCrashCallback(@Nullable CrashCallback callback)

Sets a callback that is invoked when a vehicle crash is detected.

Parameters

callback

setTripProfileListener()

Deprecated

This method was deprecated in v4.21.0, as part of the Trip Profiling feature deprecation.

void setTripProfileListener(@Nullable TripProfileListener tripProfileListener)

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 a TransportSegment of type VehicleMode.VEHICLE.

Parameters

tripProfileListener

setTripTimeoutListener()

void setTripTimeoutListener(@Nullable TripTimeoutListener listener)

To learn more about trip timeouts, see controlled detections.

Parameters

listener

setUserActivityListener()

void setUserActivityListener(@Nullable UserActivityListener listener)

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

setVehicleCrashListener()

void setVehicleCrashListener(@Nullable VehicleCrashListener listener)

Sets a listener that is invoked when a vehicle crash is detected.

Parameters

listener

start()

void start(OnStartFinishedHandler handler)

Starts the SDK detections.

Parameters

handler

start()

void start(Date stopDate, OnStartFinishedHandler handler)

Starts the SDK detections.

Parameters

stopDate

An absolute date at which the SDK is stopped. If the date is in the past, the SDK will stop immediately.

handler

startTrip()

void startTrip(@Nullable Map<String, String> metadata, 
               @Nullable TransportMode transportModeHint, 
               @Nullable StartTripCallback callback)

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

callback

stop()

void stop()

Stops the SDK detections.

stopTrip()

void stopTrip(@Nullable StopTripCallback callback)

To learn more about external trips, see controlled detections.

Parameters

callback

submitDetections()

void submitDetections(@Nullable SubmitDetectionsCallback callback)

Submits the detections to the Sentiance API. This will bypass any network quota limitation.

Parameters

callback

updateSdkNotification()

void updateSdkNotification(Notification notification)

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

updateTripProfileConfig()

void updateTripProfileConfig(TripProfileConfig tripProfileConfig)

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.

A object.

For more information regarding failure, see .

A callback to handle the token result. Note that the SDK holds a to this callback in order to prevent component leaks. Make sure you have a strong reference to it in order to guarantee its execution.

All methods in this class (except this method, , and ) will throw an SdkException when called before initialization has completed.

An representing the SDK configuration.

An to handle the initialization of the Sdk.

Calling this method will invoke the method of your CrashCallback implementation, set via .

A enum indicating the type of trip for which you want to check.

A enum indicating the type of trip the caller is interested in.

A to handle the reset completion.

This method is deprecated. Use instead.

A object to receive crash time and location.

A to handle a new , or null to remove the previous listener.

Sets a listener that is invoked when a trip times out. This method is relevant only when triggered trips are enabled via on the SdkConfig.Builder object. Trips do not time out otherwise.

A to handle trip timeouts, or null to remove the previous listener.

A to handle changes, or null to remove the previous listener.

A to receive details about the crash. Set null to remove the previously set listener.

When this process has finished, will be called. This does not necessarily mean that the SDK is actually performing detections. You may use the SdkStatus passed to the method to determine why.

To automatically stop detections, call the method instead. You do not need to call beforehand as all start calls override each other.

A used to notify that the SDK start has finished. Note that the SDK holds a to this handler to in order to prevent component leaks. Make sure you have a strong reference to it in order to guarantee its execution.

This method has the same behaviour as 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 . You do not need to call beforehand as all start calls override each other.

A used to notify that the SDK start has finished. Note that the SDK holds a to this handler to in order to prevent component leaks. Make sure you have a strong reference to it in order to guarantee its execution.

A hint indicating the type of transport being used, if known.

A to handle trip start success and failure.

Stops the currently ongoing external trip (started by calling ).

A to handle trip stop success and failure.

�A typical use case of this method would be when the enclosing app determines (via or ) that there are too many detections on disk that have not yet been submitted.

A invoked with the result.

A used by the SDK when starting a foreground service.

Context
weak reference
SdkConfig
OnInitCallback
TripType
TripType
ResetCallback
CrashCallback
TripProfileListener
TripProfile
TripTimeoutListener
UserActivityListener
UserActivity
VehicleCrashListener
OnStartFinishedHandler
weak reference
OnStartFinishedHandler
weak reference
TransportMode
StartTripCallback
StopTripCallback
SubmitDetectionsCallback
Notification
init()
reset(ResetCallback)
getInitState()
getVersion()
setVehicleCrashListener(VehicleCrashListener)
start(Date, OnStartFinishedHandler)
stop()
start(OnStartFinishedHandler)
start(OnStartFinishedHandler)
stop()
starTrip()
setCrashCallback(CrashCallback)
getDiskQuotaUsage()
TokenResultCallback.onFailure()
setTriggeredTripsEnabled(boolean)
SdkStatus.diskQuotaStatus
OnStartFinishedHandler.onStartFinished(SdkStatus)
onStartFinished(SdkStatus)
onCrash(long, Location)