Since upgrading to 12.20 I have been unable to get geofencing to work properly and I am not sure why.
I ran the Geofencing tutorial sample that Erel made and I consistently get an error in the GeofenceService module.
(Intent) Intent { cmp=b4a.geofence/.geofenceservice }
Error occurred on line: 26 (GeofenceService)
java.lang.RuntimeException: Object should first be initialized (JavaObject).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67)
Sub Service_Start (StartingIntent As Intent)
Log(StartingIntent)
Dim GeofencingEvent As JavaObject
GeofencingEvent.InitializeStatic("com.google.android.gms.location.GeofencingEvent")
** THIS LINE IS ALWAYS A BLANK RETURN** GeofencingEvent = GeofencingEvent.RunMethod("fromIntent", Array(StartingIntent))
Dim transtion As Int = GeofencingEvent.RunMethod("getGeofenceTransition", Null)
If transtion > 0 Then
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 transtion = 1 Then
CallSubDelayed2(Starter, "Geofence_Enter", id)
Else If transtion = 2 Then
CallSubDelayed2(Starter, "Geofence_Exit", id)
End If
End If
End If
Service.StopAutomaticForeground
End Sub
Any insight would be appreciated.
I ran the Geofencing tutorial sample that Erel made and I consistently get an error in the GeofenceService module.
(Intent) Intent { cmp=b4a.geofence/.geofenceservice }
Error occurred on line: 26 (GeofenceService)
java.lang.RuntimeException: Object should first be initialized (JavaObject).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67)
Sub Service_Start (StartingIntent As Intent)
Log(StartingIntent)
Dim GeofencingEvent As JavaObject
GeofencingEvent.InitializeStatic("com.google.android.gms.location.GeofencingEvent")
** THIS LINE IS ALWAYS A BLANK RETURN** GeofencingEvent = GeofencingEvent.RunMethod("fromIntent", Array(StartingIntent))
Dim transtion As Int = GeofencingEvent.RunMethod("getGeofenceTransition", Null)
If transtion > 0 Then
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 transtion = 1 Then
CallSubDelayed2(Starter, "Geofence_Enter", id)
Else If transtion = 2 Then
CallSubDelayed2(Starter, "Geofence_Exit", id)
End If
End If
End If
Service.StopAutomaticForeground
End Sub
Any insight would be appreciated.