Reputation: 45
I am making a geofencing application, which must trigger notification constantly while the device is outside the geofence, not only on exit.
I have tried using Geofencing API through the training example given in Google android developer training page. But, I got notification only when the device enters, dwell or exit.
According to what I have researched till now in both SO and google, there are only three types of transitions handled in Geofencing API: Enter, Dwell and Exit. And the notification starts only when device enters the geofence, till it exits.
Can anyone help me out how to make it work?
Upvotes: 3
Views: 940
Reputation: 1517
Incase you want your own custom exit trigger, when you are outside the fence. You can write your custom action by measuring distance(lat,long) between your current location(FusedLocationProvider) and the fence location (lat, long).
You can use below methods available in Android Location API to measure the difference and generate a custom trigger to indicate that you are outside the fence.
Typically this is what you need to do
if[ (difference in location) > (Radius of your geo fence) ] -> Custom Exit of Fence Action
Upvotes: 2
Reputation: 8073
That is not possible that way. It does not make any sense outside the geofence area. That is not an usecase of geofence.
You can try to specify broader range of the area and then check the geocoordinates if this is outside of your area you want to have.
Upvotes: 1