Search in sources :

Example 6 with GeofencingEvent

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);
    }
}
Also used : GeofencingEvent(com.google.android.gms.location.GeofencingEvent)

Example 7 with GeofencingEvent

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);
}
Also used : NotificationManager(android.app.NotificationManager) NotificationCompat(android.support.v4.app.NotificationCompat) Notification(android.app.Notification) GeofencingEvent(com.google.android.gms.location.GeofencingEvent)

Aggregations

GeofencingEvent (com.google.android.gms.location.GeofencingEvent)7 Geofence (com.google.android.gms.location.Geofence)3 Notification (android.app.Notification)2 NotificationManager (android.app.NotificationManager)2 NotificationCompat (android.support.v4.app.NotificationCompat)2 Location (android.location.Location)1 ArraySet (android.support.v4.util.ArraySet)1 ArrayList (java.util.ArrayList)1 GeoEventType (org.infobip.mobile.messaging.geo.GeoEventType)1 GeoLatLng (org.infobip.mobile.messaging.geo.GeoLatLng)1 RemindyDAO (ve.com.abicelis.remindy.database.RemindyDAO)1 CouldNotGetDataException (ve.com.abicelis.remindy.exception.CouldNotGetDataException)1 Task (ve.com.abicelis.remindy.model.Task)1