NOTE: This is a rewrite of this post, which might contain relevant information (but I doubt it)
I'm working with geofence code posted by Erel: https://www.b4x.com/android/forum/threads/geofence-monitoring-a-region-in-the-background.84767/
In many ways it works just fine, but at some point it fails to add geofences when I relaunch the app. This is evident as the isSuccessful returns FALSE.
The good news is that the geofence thing in Android can tell you what went wrong, using GeofenceStatusCodes. The bad news is that I just can't seem to navigate JavaObjects, GetMethods, etc well enough to find my way to that information.
The example linked above contain the following sub by Erel. I tried to work my way to GeofenceStatusCodes. The last two lines in the sub is as far as I came, but I suspect I'm on the wrong path.
Given what we have in the sub, can somebody help me find my way to the value for GeofenceStatusCodes so I can understand what the problem is?
Relevant (I think) documentation at Google:
I'm working with geofence code posted by Erel: https://www.b4x.com/android/forum/threads/geofence-monitoring-a-region-in-the-background.84767/
In many ways it works just fine, but at some point it fails to add geofences when I relaunch the app. This is evident as the isSuccessful returns FALSE.
The good news is that the geofence thing in Android can tell you what went wrong, using GeofenceStatusCodes. The bad news is that I just can't seem to navigate JavaObjects, GetMethods, etc well enough to find my way to that information.
The example linked above contain the following sub by Erel. I tried to work my way to GeofenceStatusCodes. The last two lines in the sub is as far as I came, but I suspect I'm on the wrong path.
B4X:
Public Sub AddGeofence(Callback As Object, geo As Geofence)
Dim gb As JavaObject = CreateGeofenceBuilder(geo)
Dim req As JavaObject = CreateGeofenceRequest(gb)
Dim task As JavaObject = client.RunMethod("addGeofences", Array(req, PendingIntent))
Do While task.RunMethod("isComplete", Null) = False
Sleep(50)
Loop
CallSubDelayed2(Callback, "Geofence_Added", task.RunMethod("isSuccessful", Null))
' Below added by me
Dim exc As JavaObject = task.RunMethod("getException", Null)
Log(exc.RunMethod("getStatusCode", Null))
End Sub
Given what we have in the sub, can somebody help me find my way to the value for GeofenceStatusCodes so I can understand what the problem is?
Relevant (I think) documentation at Google: