GeotriggerMonitor

class GeotriggerMonitor

A GeotriggerMonitor monitors a Geotrigger condition and, when it is met, results in a GeotriggerNotificationInfo. A Geotrigger defines a query that is evaluated against GIS data as it changes in real time. For example, "Notify me when my device location enters one of my target areas" or "Notify me when my device location is within 50 m of my destination".

A GeotriggerMonitor is created with a Geotrigger that it continually checks to determine whether the condition has been met.

Once a GeotriggerMonitor is created, you begin checking the condition by calling GeotriggerMonitor.start(). Once you are finished, call GeotriggerMonitor.stop(). When a Geotrigger evaluates to true, a GeotriggerMonitor.onGeotriggerNotificationEvent is sent. You can subscribe to the notification info to receive details of where the Geotrigger was activated and the condition that was met.

Constructors

Link copied to clipboard
fun GeotriggerMonitor(geotrigger: Geotrigger)

Constructs a GeotriggerMonitor with a Geotrigger condition.

Functions

Link copied to clipboard
suspend fun start(): Result<Unit>

Starts evaluating the GeotriggerMonitor. When the GeotriggerMonitor is successfully performing checks, the GeotriggerMonitor.getStatus() will be GeotriggerMonitorStatus.Started.

Link copied to clipboard
fun stop()

Stops evaluating the GeotriggerMonitor. Stopping the GeotriggerMonitor prevents the condition from being evaluated and notifications from being sent. If you are using a LocationGeotriggerFeed created from a LocationDataSource, the data source must also be stopped to turn off GPS receivers etc.

Properties

Link copied to clipboard
val geotrigger: Geotrigger
Link copied to clipboard
val geotriggerNotificationEvent: SharedFlow<GeotriggerNotificationInfo>

Indicates that the GeotriggerMonitor condition has been meet.

Link copied to clipboard
val status: StateFlow<GeotriggerMonitorStatus>

The current monitoring status of the GeotriggerMonitor. A GeotriggerMonitor begins with a monitoring status of GeotriggerMonitorStatus.Stopped and changes to GeotriggerMonitorStatus.Started when you call GeotriggerMonitor.start(). When you call GeotriggerMonitor.stop(), the monitoring status changes to GeotriggerMonitorStatus.Stopped.

Link copied to clipboard
val warning: StateFlow<Throwable?>

An error that describes a problem encountered while starting or monitoring the Geotrigger. A warning can occur at various stages of monitoring a Geotrigger: