Helo there.
I'm working with ArcGIS Runtime for Android (written in Kotlin) and most of basic functions works fine. I can show device position (with high accuracy) and load a WebMap where are two FeatureServices. Those services are providing features for geofences.
First test looks like it was working fine, the device is inside one of the geofences a triggers GeotriggerMonitor notification for ENTER event. Continuing with the test, the device leaves geofence and nothing happen.
Also, I tested the opposite situation, starts out of geofence and then enter but, nothing happen either.
The source is similar to this example: this .
There're same syntax differences but, the main difference cloud be related with where MapView is placed. It's in a Fragmente instead of in an Activity.
My code:
GeotriggerMonitor setup:
private fun setupComplejoGeotriggers(){
val locationFeed = LocationGeotriggerFeed(mapView.locationDisplay.locationDataSource)
//Geofences Layer
complejosLayer?.let { layer ->
val fenceParameters = FeatureFenceParameters(layer.featureTable)
val predioGeotrigger = FenceGeotrigger(locationFeed, FenceRuleType.ENTER_OR_EXIT,fenceParameters, null, "EnterComplejo")
val geotriggerMonitor = GeotriggerMonitor(predioGeotrigger)
geotriggerMonitor.addGeotriggerMonitorNotificationEventListener(onComplejoEnterEvent)
geotriggerMonitor.addGeotriggerMonitorWarningChangedEventListener(onGeotriggerEvent)
val future = geotriggerMonitor.startAsync()
// check to see if the GeotriggerMonitor failed to start
future.addDoneListener {
if (geotriggerMonitor.status == GeotriggerMonitorStatus.FAILED_TO_START) {
val message = "GeotriggerMonitor failed to load: " +
geotriggerMonitor.warning.message +
geotriggerMonitor.warning.additionalMessage
Log.e("GEOPDM", message)
}
}
Log.d(TAG, "Complejo dection ready")
}
}
Notifications Handler:
private val onComplejoEnterEvent =
GeotriggerMonitorNotificationEventListener { complejoEnterEvt ->
val notifInfo =
complejoEnterEvt.geotriggerNotificationInfo as FenceGeotriggerNotificationInfo
val fence = notifInfo.fenceGeoElement
val truck = notifInfo.feedLocation.position
val prefdioFeature = fence as ArcGISFeature
val idLugar = prefdioFeature.attributes["ID_LUGAR"]
showTost("Destino ${notifInfo.fenceNotificationType} - $idLugar")
}
Warning Handler:
private val onGeotriggerEvent =
GeotriggerMonitorWarningChangedEventListener { warnEvt ->
Log.d(TAG, "Trigger w")
Log.d(TAG, "Predio $warnEvt")
Log.d(TAG, "Predio $warnEvt", warnEvt.warning)
}
Thank you very much!
Hope somebody can help me!