/** * Handles incoming intents. * * @param intent sent by Location Services. This Intent is provided to Location Services (inside a * PendingIntent) when addGeofences() is called. */ @Override protected void onHandleIntent(Intent intent) { GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent); if (geofencingEvent.hasError()) { String errorMessage = GeofenceErrorMessages.getErrorString(this, geofencingEvent.getErrorCode()); Log.e(TAG, errorMessage); return; } // Get the transition type. int geofenceTransition = geofencingEvent.getGeofenceTransition(); // Test that the reported transition was of interest. if (geofenceTransition == Geofence.GEOFENCE_TRANSITION_ENTER || geofenceTransition == Geofence.GEOFENCE_TRANSITION_EXIT) { // Get the geofences that were triggered. A single event can trigger multiple geofences. List<Geofence> triggeringGeofences = geofencingEvent.getTriggeringGeofences(); // Get the transition details as a String. String geofenceTransitionDetails = getGeofenceTransitionDetails(this, geofenceTransition, triggeringGeofences); // Send notification and log the transition details. Notification.sendNotification(this, geofenceTransitionDetails); Log.i(TAG, geofenceTransitionDetails); // LocalBroadcastManager.getInstance(this).sendBroadcast(new // Intent(GEOFENCE_TRANSITION) // .putExtra(GEOFENCE_TRANSITION_DETAILS, geofenceTransitionDetails)); } else { // Log the error. Log.e(TAG, getString(R.string.geofence_transition_invalid_type, geofenceTransition)); } }