Jump to content
Sign in to follow this  
Dave Nottage

Seeking help to make Geofencing on Android work in a Delphi app

Recommended Posts

Background:

 

I'm working on an implementation of Geofencing on Android, based on this documentation: https://developer.android.com/training/location/geofencing

 

..and based on their example on Github: https://github.com/android/location-samples/tree/master/Geofencing

 

To be able to help with this, you will likely need some Java skills, and know about Android intents and receivers. I don't know completely everything about them, hence the request for help

 

Demo:

 

I've attached the work in progress demo, which should compile as-is, i.e. it should not be dependent on anything - it uses files from Kastri, but I have copied them into the project.

 

I've also included the source for the Java parts, as a reference. The corresponding binary is dw-geofence.jar, which is included in the Lib folder of the project.

 

The demo sets up 3 geofence regions. Tapping the Start button first requests location permissions - in order for geofencing to work, you need to tap on "Allow in settings":

image.thumb.png.180b7f6b7e290efededccf239ea5ce35.png

 

..and select the "Allow all the time" option:
image.thumb.png.fc65ab762bd1868600be75e54c88a0ca.png  

 

(then tap the back arrow at the top)

 

If geofence starts successfully, a message will appear in the memo: Action: 1, Result: 0, Message:  (Action of 1 = start monitoring, Result of 0 = success)

 

Simulating changes in location:

 

So that you don't actually have to physically move anywhere, fortunately on Android it is possible to simulate location changes by using a "mock gps" app, such as this one: https://play.google.com/store/apps/details?id=org.hola.gpslocation

 

Once installed, you need to go into the Developer Options of the Settings app on the device, and set the mock locations app:

 

image.thumb.png.24d47ac3c0c14b4f994b0c2f17de6829.png

 

Then use the mock locations app to change your location to one of the geofence regions created by the AddRegions method of TMainView in AG.View.Main in the project.

 

The problem 

 

I find that when moving into/out of the regions, the GeofenceIntentReceiver is not being "triggered", i.e. onReceive is not being called.

 

If someone is able to help, it would be greatly appreciated. 

 

 

AGDemo.zip

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×