You’re close, but intermittent geofence triggers are a known pain point in Android due to a mix of power optimizations, background restrictions, and subtle lifecycle issues. Here are 10 critical checks and recommendations to ensure your geofencing is more reliable:
You’re not actively requesting LocationUpdates — that’s fine for geofence-only logic. But adding a passive location request can help keep Play Services “warm” and improve accuracy:
val request = LocationRequest.create().apply {
priority = LocationRequest.PRIORITY_HIGH_ACCURACY
interval = 10_000
}
fusedLocationClient.requestLocationUpdates(request, locationCallback, Looper.getMainLooper())
Calling addGeofences() multiple times with same requestId or without calling removeGeofences() first can make things flaky.
Consider clearing old geofences before re-registering:
geofencingClient.removeGeofences(geofencePendingIntent).addOnCompleteListener {
addGeofenceRequest()
}
You’re doing most things right — the remaining 10% is getting Android’s behavior under real-world,
Please share the manifest with permission and receiver