use of com.google.android.gms.location.GeofencingEvent in project hypertrack-live-android by hypertrack.
the class GeofenceTransitionsIntentService method onHandleIntent.
@Override
protected void onHandleIntent(Intent intent) {
if (intent != null) {
GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent);
if (geofencingEvent.hasError()) {
String errorMessage = ErrorMessages.getGeofenceErrorString(this, geofencingEvent.getErrorCode());
HyperLog.e(TAG, errorMessage);
return;
}
// Get the transition type.
int geofenceTransition = geofencingEvent.getGeofenceTransition();
if (geofenceTransition == Geofence.GEOFENCE_TRANSITION_DWELL) {
HyperLog.i(TAG, "User is dwelling in geo fence.");
ActionManager.getSharedManager(getApplicationContext()).OnGeoFenceSuccess();
} else {
// Log the error.
HyperLog.e(TAG, getString(R.string.geofence_transition_invalid_type, geofenceTransition));
}
// Get the geofences that were triggered. A single event can trigger
// multiple geofences.
String geofenceTransitionDetails = getGeofenceTransitionDetails(geofenceTransition, geofencingEvent.getTriggeringGeofences());
HyperLog.i(TAG, "GeoFenceTransition Details: " + geofenceTransitionDetails);
}
}
use of com.google.android.gms.location.GeofencingEvent in project Android-ReactiveLocation by mcharmas.
the class GeofenceBroadcastReceiver method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
GeofencingEvent event = GeofencingEvent.fromIntent(intent);
String transition = mapTransition(event.getGeofenceTransition());
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new NotificationCompat.Builder(context).setSmallIcon(R.drawable.ic_launcher).setContentTitle("Geofence action").setContentText(transition).setTicker("Geofence action").build();
nm.notify(0, notification);
}
Aggregations