protected override void OnHandleIntent(Intent intent)
        {
            GeofencingEvent geofencingEvent = GeofencingEvent.FromIntent(intent);

            if (geofencingEvent.HasError)
            {
                string errorMessage = GeofenceErrorMessages.GetErrorString(this, geofencingEvent.ErrorCode);
                Log.Error(TAG, errorMessage);
                return;
            }

            int geofenceTransition = geofencingEvent.GeofenceTransition;

            if (geofenceTransition == Android.Gms.Location.Geofence.GeofenceTransitionEnter ||
                geofenceTransition == Android.Gms.Location.Geofence.GeofenceTransitionExit)
            {
                var triggeringGeofences = geofencingEvent.TriggeringGeofences;

                String geofenceTransitionDetails = GetGeofenceTransitionDetails(this, geofenceTransition,
                                                                                triggeringGeofences);

                SendNotification(geofenceTransitionDetails);
                Log.Info(TAG, geofenceTransitionDetails);
            }
            else
            {
                Log.Error(TAG, GetString(Resource.String.geofence_transition_invalid_type, geofenceTransition));
            }
        }
Example #2
0
        public void OnResult(Java.Lang.Object rawStatus)
        {
            var status = Extensions.JavaCast <IResult>(rawStatus);

            if (status.Status.IsSuccess)
            {
                mGeofencesAdded = !mGeofencesAdded;
                ISharedPreferencesEditor editor = mSharedPreferences.Edit();
                editor.PutBoolean(Constants.GEOFENCES_ADDED_KEY, mGeofencesAdded);
                editor.Commit();

                SetButtonsEnabledState();

                Toast.MakeText(this, GetString(mGeofencesAdded ? Resource.String.geofences_added : Resource.String.geofences_removed), ToastLength.Short).Show();
            }
            else
            {
                string errorMessage = GeofenceErrorMessages.GetErrorString(this, status.Status.StatusCode);
                Log.Error(TAG, errorMessage);
            }
        }