Tracking Connections

The component framework tracks the set of connections specified for a component in ComponentInfo if the locationServiceUsage property is set to RegisterAndTrackServices. The framework also provides a helper trackConnection method to track any connection other than those present in ComponentInfo.

onLocationTrackingEvent

The onLocationTrackingEvent handler can be used to take action on the TrackingEvent for a particular connection. This event could be for the connections in ComponentInfo tracked automatically or for the connections tracked explicitly using trackConnection method.

Assembly/Scala
sourceoverride def onLocationTrackingEvent(trackingEvent: TrackingEvent): Unit =
  trackingEvent match {
    case LocationUpdated(location)   => // do something for the tracked location when it is updated
    case LocationRemoved(connection) => // do something for the tracked location when it is no longer available
  }
Assembly/Java
source@Override
public void onLocationTrackingEvent(TrackingEvent trackingEvent) {
    if (trackingEvent instanceof LocationUpdated) {
        // do something for the tracked location when it is updated
    } else if (trackingEvent instanceof LocationRemoved) {
        // do something for the tracked location when it is no longer available
    }
}
Hcd/Scala
sourceoverride def onLocationTrackingEvent(trackingEvent: TrackingEvent): Unit =
  trackingEvent match {
    case LocationUpdated(location)   => // do something for the tracked location when it is updated
    case LocationRemoved(connection) => // do something for the tracked location when it is no longer available
  }
Hcd/Java
source@Override
public void onLocationTrackingEvent(TrackingEvent trackingEvent) {
    if (trackingEvent instanceof LocationUpdated) {
        // do something for the tracked location when it is updated
    } else if (trackingEvent instanceof LocationRemoved) {
        // do something for the tracked location when it is no longer available
    }
}