EDIT: I re-read my own post and found it to be overly wordy, confusing and focused on the wrong thing. I'm leaving this here for posterity, and in case it might contain something relevant. New post that hopefully is clearer: https://www.b4x.com/android/forum/threads/getting-info-using-javaobjects-getmethod-etc.128173/
I'm experimenting with geofences on Android (related thread) and have come upon something I can't seem to solve.
I've taken the example by Erel (see the related thread above) and modified Main slightly to add more than one geofence. It seemed to work for a period, but then it stopped working by simply not allowing to add more geofences at app relaunch.
In GeofenceService there is this code, as Erel wrote it:
Look at the last line. The isSuccessful returns TRUE initially, but then switches to FALSE after a couple (one?) of app relaunches.
I've been looking at the documentation that seem relevant to me:
When I run this, the Log at the bottom returns 13, which doesn't match the listed values for GeofenceStatusCodes even a little bit. So I think I'm completely lost here.
Any suggestions?
I'm experimenting with geofences on Android (related thread) and have come upon something I can't seem to solve.
I've taken the example by Erel (see the related thread above) and modified Main slightly to add more than one geofence. It seemed to work for a period, but then it stopped working by simply not allowing to add more geofences at app relaunch.
In GeofenceService there is this code, as Erel wrote it:
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))
End Sub
Look at the last line. The isSuccessful returns TRUE initially, but then switches to FALSE after a couple (one?) of app relaunches.
I've been looking at the documentation that seem relevant to me:
- GeofencingClient
GeofencingClient | Google Play services | Google for Developers
developers.google.com
- Task
Task | Google Play services | Google for Developers
developers.google.com
- GeofenceStatusCodes
GeofenceStatusCodes | Google Play services | Google for Developers
developers.google.com
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
When I run this, the Log at the bottom returns 13, which doesn't match the listed values for GeofenceStatusCodes even a little bit. So I think I'm completely lost here.
Any suggestions?
Last edited: