Aplicación Android de chat con amigos, utilizando los servicios de ubicación de Google Play y que detecta cuando el dispositivo entra/sale de zonas geográficas definidas (geovallas).
Android SDK 24+
Google Play Services 21+
Permisos de ubicación (en primer y segundo plano)
✅ Creación de geovallas circulares
✅ Notificaciones locales en tiempo real
✅ Deteccion de geovallas cercanas
🛠 Integración con Google Maps
🛠 Histórico de eventos en la nube
🛠 Modo de bajo consumo energético
🔍 Geovallas con formas personalizadas
👥 Geofencing colaborativo
Client: Java, XML, Android SDK
Server: Firebase Auth, GooglePlay Services
Geofencing App - API Reference
Runtime Permission Request
Permission
Description
Required For
ACCESS_FINE_LOCATION
Precise GPS location
Geofence creation
ACCESS_COARSE_LOCATION
Approximate network location
Fallback option
ACCESS_BACKGROUND_LOCATION
Background location access (Android 10+)
Persistent geofencing
new Geofence .Builder ()
.setRequestId ("geofence_id" )
.setCircularRegion (latitude , longitude , radius )
.setExpirationDuration (Geofence .NEVER_EXPIRE )
.setTransitionTypes (Geofence .GEOFENCE_TRANSITION_ENTER | Geofence .GEOFENCE_TRANSITION_EXIT )
.build ();
Parameter
Type
Description
requestId
String
Unique identifier for the geofence
latitude
double
Center point latitude
longitude
double
Center point longitude
radius
float
Radius in meters (min 100m recommended)
geofencingClient .addGeofences (geofencingRequest , pendingIntent );
Parameter
Type
Description
geofencingRequest
GeofencingRequest
Configured geofence request
pendingIntent
PendingIntent
Intent to trigger on geofence events
public class GeofenceBroadcastReceiver extends BroadcastReceiver {
@ Override
public void onReceive (Context context , Intent intent ) {
GeofencingEvent event = GeofencingEvent .fromIntent (intent );
// Handle enter/exit events
}
}
Transition Type
Description
GEOFENCE_TRANSITION_ENTER
Triggered when device enters geofence
GEOFENCE_TRANSITION_EXIT
Triggered when device exits geofence
1. Geofence Event Endpoint
POST /api/geofence/events
Parameter
Type
Description
device_id
string
Required . Device identifier
geofence_id
string
Required . Geofence identifier
event_type
string
"ENTER" or "EXIT"
timestamp
datetime
Event occurrence time
Parameter
Type
Description
device_token
string
Required . FCM registration token
message
string
Notification content
geofence_data
object
Related geofence information
Returns the device's last known location.
fusedLocationClient .getLastLocation ()
.addOnSuccessListener (location -> {
// Use location data
});
createGeofencePendingIntent()
Creates a PendingIntent for geofence transitions.
private PendingIntent getGeofencePendingIntent () {
Intent intent = new Intent (context , GeofenceBroadcastReceiver .class );
return PendingIntent .getBroadcast (context , 0 , intent , PendingIntent .FLAG_IMMUTABLE );
}
implementation ' com.google.android.gms:play-services-location:21.0.1'
implementation ' androidx.core:core-ktx:1.12.0'