Sub Service_Start (StartingIntent As Intent) 'StartingIntent is always null
Dim GeofencingEvent As JavaObject
GeofencingEvent.InitializeStatic("com.google.android.gms.location.GeofencingEvent")
GeofencingEvent = GeofencingEvent.RunMethod("fromIntent", Array(StartingIntent))
Dim transition As Int = GeofencingEvent.RunMethod("getGeofenceTransition", Null) ' Always returns -1
Log("GeofenceService Service_Start")
Log("transition:" & transition)
If transition > 0 Then 'Because the transition is always -1 it never evaluates the following code
Dim geofences As List = GeofencingEvent.RunMethod("getTriggeringGeofences", Null)
If geofences.Size > 0 Then
Dim geofence As JavaObject = geofences.Get(0)
Dim id As String = geofence.RunMethod("getRequestId", Null)
If transition = 1 Then
CallSubDelayed2(Starter, "Geofence_Enter", id)
Else If transition = 2 Then
CallSubDelayed2(Starter, "Geofence_Exit", id)
End If
End If
End If
End Sub