Safe Rider

class SafeRider

Entry point of the SafeRider SDK.

Create and initialize a singleton via initialize and access it through sharedInstance.

Main features:

  • Start/stop protection and observe state changes via protectionStatusFlow or status.

  • Handle the accident workflow (countdown and alarm) when showAccidentUi is true.

  • Enable/disable automatic trip detection and manually start/stop trips.

  • Expose current trip status via tripStatus and tripStatusFlow.

Lifecycle:

  • The SDK runs a foreground service while protection is active.

  • Trip detection enablement and settings are persisted across app restarts.

Threading:

  • Public APIs are intended to be called from the main thread. Internals rely on coroutines.

Types

Link copied to clipboard
object Companion
Link copied to clipboard

Listener for fall survey answers after the accident workflow

Link copied to clipboard
sealed class LRTripStatus

Represents the current trip status exposed by the SDK.

Link copied to clipboard

Listener for LRTripStatus changes.

Link copied to clipboard

Listener for protection status changes

Properties

Link copied to clipboard
Link copied to clipboard

Listener for protection status changes events

Link copied to clipboard
Link copied to clipboard

The current protection status

Link copied to clipboard

The current trip detection configuration

Link copied to clipboard

the current trip status

Link copied to clipboard

A flow of trip status changes

Link copied to clipboard

Functions

Link copied to clipboard

Add a listener for protection status changes The listener will be notified when the protection status changes

Link copied to clipboard
fun addTripDetectionListener(listener: LRTripDetectionListener)

Add a listener for trip detection events

Link copied to clipboard

Add a listener for trip status changes The listener will be notified when the trip status changes

Link copied to clipboard

Cancel the emergency request Do nothing if the is no current emergency request This method should not be handled by the client if @property showAccidentUi is set to true as the library will handle it.

Link copied to clipboard

Disable trip detection

Link copied to clipboard
fun enableTripDetection(vehicleType: LRVehicleType, useTrainLinesDetection: Boolean = false, resultListener: (LRResult) -> Unit? = null)

Enable trip detection Trip detection will scan the user activity to detect trips for the given vehicle type. When a trip is detected, the library will notify the client with the detected vehicle by calling the LRTripDetectionListener.onTripDetected(vehicleType) method for registered listeners. This method will check if the required permissions are granted before enabling trip detection. If not, it will return an error. This state is persisted and will be restored when the application is killed and restarted so that the client doesn't need to enable trip detection again.

Link copied to clipboard

Get the intent to start the accident workflow activity Return the intent to start the accident workflow activity when an accident is detected.

Link copied to clipboard
fun getConfigurationErrors(blockingErrorsOnly: Boolean = false): List<LRSafeRiderError>
Link copied to clipboard

Remove all protection status listeners

Link copied to clipboard

Remove a listener for protection status changes Stops receiving protection status changes for the given listener

Link copied to clipboard
fun removeTripDetectionListener(listener: LRTripDetectionListener)

Remove a listener for trip detection

Link copied to clipboard
fun removeTripStatusListener(listener: SafeRider.LRTripStatusListener): <Error class: unknown class>

Remove a listener for trip status changes Stops receiving trip status changes for the given listener

Link copied to clipboard

Report an undetected accident during the protection session This method will upload session data buffers to the server

Link copied to clipboard

Resume to an active state after an emergency This method should not be handled by the client if @property showAccidentUi is set to true as the library will handle it. In scenarios where the client wants to handle the emergency state by itself, this method should be called to resume the protection at the end of the emergency worfklow.

Link copied to clipboard

Send a fake emergency request

Link copied to clipboard
fun simulateFakeShock(shockDate: Long = LRDateTime.currentMillis())

Simulate a fake shock warning: this method should only be used for testing purposes

Link copied to clipboard
fun startProtection(vehicleType: LRVehicleType, userId: String, phoneNumber: String, firstName: String?, lastName: String?, metadata: Map<String, Any>?): LRResult

Start the protection

Link copied to clipboard

Start a trip manually if a trip is already ongoing, this method returns the current trip status

Link copied to clipboard

Stop the alert countdown after an accident detected This method should not be handled by the client if @property showAccidentUi is set to true as the library will handle it.

Link copied to clipboard

Stop the protection

Link copied to clipboard
fun stopTrip()

Stop the current trip

Link copied to clipboard
fun triggerFakeAlert(location: Location)

Trigger a fake alert warning: this method should only be used for testing purposes

Link copied to clipboard
fun triggerTripDetectionAnalysis(vehicleType: LRVehicleType)

Trigger a fake detection analysis by emulating an activity recognition event warning: this method should only be used for testing purposes