Geofencing in mobile apps: how it works on Android, and what to expect
Understand Android geofence permissions, radius choices, delayed alerts and re-registration requirements before depending on arrival events.
Delivery, logistics, field-service and retail apps often need to react when a device arrives at or leaves a place. Android's geofencing guide (https://developer.android.com/develop/sensors-and-location/location/geofencing) describes how this works on Android, and it is candid about delays and failure cases.
What a geofence is
Per the guide, a geofence is a circular area defined by a latitude, longitude and radius. You can ask Location Services for entrance and exit events, or for a "dwell" event after the device has stayed inside for a set time. A geofence can have an expiry. The guide says an app can have up to 100 active geofences per device user.
Permissions
The app must request ACCESS_FINE_LOCATION, and ACCESS_BACKGROUND_LOCATION if it targets Android 10 (API level 29) or higher. Background location is a permission users can refuse, so the feature needs a fallback and a clear in-app explanation.
Design advice from Android
- Radius. The guide says the minimum radius should be between 100 and 150 meters for best results. With Wi-Fi it says accuracy is usually 20 to 50 meters (assume about 50 unless indoor location is available); without Wi-Fi, such as driving in rural areas, accuracy can degrade to several hundred meters or kilometers, so use a larger radius.
- Dwell, not enter, to reduce "alert spam" when a device briefly crosses a boundary.
- Responsiveness. Higher values (slower alerts) save power; lower values do not guarantee faster alerts.
- Larger radius for long-stay places such as home or work reduces how often the system checks.
- Stop monitoring when not needed, to save battery.
- The guide does not recommend the geofencing APIs on Wear devices, because they do not use power efficiently.
When alerts do not arrive, or arrive late
The guide's troubleshooting list includes: Wi-Fi turned off, no reliable network connectivity inside the geofence (the service depends on the network location provider), and late alerts. It says the service does not continuously query for location, usually latency is less than 2 minutes, about 2 to 3 minutes on average when background location limits apply, and may reach up to 6 minutes if the device has been stationary for a long time.
What survives restarts
Per the guide, the system restores geofences after Google Play services upgrades or restarts, and after a location process crash. The app must re-register geofences after a device reboot, app reinstall, clearing app data or Google Play services data, or a GEOFENCE_NOT_AVAILABLE alert.
What this means when scoping a product
- Treat geofence events as "approximately arrived", not exact timestamps. Do not build features that depend on second-level accuracy, such as fines or penalties based on a single event.
- Plan boot-time re-registration and testing across phones and battery settings.
- Decide how to handle denied permissions, and what location data you store. Privacy duties vary by country and we have not researched them; ask qualified counsel.
- We cover Android only. iOS has its own APIs and limits, which we did not read.
Limits
One platform, one documentation page. We make no claims about fleet tracking products or their accuracy.
By Omnistu.