Safe
Rider
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
Listener for fall survey answers after the accident workflow
Represents the current trip status exposed by the SDK.
Listener for LRTripStatus changes.
Listener for protection status changes
Properties
Listener for protection status changes events
The current protection status
The current trip detection configuration
the current trip status
A flow of trip status changes
Functions
Add a listener for protection status changes The listener will be notified when the protection status changes
Add a listener for trip detection events
Add a listener for trip status changes The listener will be notified when the trip status changes
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.
Disable trip detection
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.
Get the intent to start the accident workflow activity Return the intent to start the accident workflow activity when an accident is detected.
Remove all protection status listeners
Remove a listener for protection status changes Stops receiving protection status changes for the given listener
Remove a listener for trip detection
Remove a listener for trip status changes Stops receiving trip status changes for the given listener
Report an undetected accident during the protection session This method will upload session data buffers to the server
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.
Send a fake emergency request
Simulate a fake shock warning: this method should only be used for testing purposes
Start a trip manually if a trip is already ongoing, this method returns the current trip status
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.
Stop the protection
Trigger a fake alert warning: this method should only be used for testing purposes
Trigger a fake detection analysis by emulating an activity recognition event warning: this method should only be used for testing purposes