Android Tutorial Geofence - Monitoring a region in the background

Status
Not open for further replies.

Beja

Expert
Licensed User
Longtime User
I found a workaround, that one can define a series of overlapped circular fences with radius of .5 * the desired rectangular width.. The number if fences corresponds to the desired resolution of the rectangle.
 

Beja

Expert
Licensed User
Longtime User
Hi Erel,
Today I tried to run the example and on one phone it just closed without notification, and on another one it said "Unfortunately, B4A Example has stopped. Open app again"
any help appreciated.
Using B4A 7.01
 

Beja

Expert
Licensed User
Longtime User
Ok Don, sorry was looking to the wrong place.
 

Christian García S.

Active Member
Licensed User
Hello, It have been implented this library in a marketing project and works perfect, but I need this library for a logistic project.

I have a question, the event Geofence is launched one time when the user enter to the geofence.

There are a way for asking which is geofence I am inside, is for validation porpuses, I know I can make a variable and save this information.

For example if the app is closed or the phone is restarted and I receive the notification, I can not use this variable for some validation, because the event is only triggered one time.

Or can you give me an idea how I can validate location??

Thanks for your help.

Regards,
Christian
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
There are a way for asking which is geofence I am inside
The event which raise contains the ID of the Fence you entered....
It is the ID you set when creating the Fence.

B4X:
   Dim geo As Geofence
   geo.Initialize
   geo.Id = "Test1" ' ID is here....
   geo.Center.Initialize2(32.8372, 35.2698) 'change location!
   geo.RadiusMeters = 100
   geo.ExpirationMs = DateTime.TicksPerDay 'expire after one day

B4X:
Public Sub Geofence_Enter (Id As String)
   Log("Enter: " & Id)
End Sub

Public Sub Geofence_Exit (Id As String)
   Log("Exit: " & Id)
End Sub
 

BillMeyer

Well-Known Member
Licensed User
Longtime User
Good Day,

I have a situation where I place a GeoFence at an Accident Scene. The time that it takes for the Accident to be cleared up is variable. After the clean up I no longer need the GeoFence and need to expire it.

Will it suffice to re-write/over write the fence and then just alter the ExpirationsMs to DateTime.Now ? or is there another way of doing this ?

If I need to create a new thread, I will, please advise.
 

Johan Hormaza

Well-Known Member
Licensed User
Longtime User
I have this problem on Android 8.1

--------- beginning of crash
--------- beginning of system
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (geofenceservice) Create ***
** Service (geofenceservice) Start **

com.google.android.gms.common.api.ApiException: 1000:
Geofence added: false


And in a Xiaomi Redmi Note 8 Android 9 it does not tell me if I am inside or outside the Geofence
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…