Пример #1
0
        //Since Java bytecode does not support generics, casting between types can be messy. Handle everything here.
        public void OnResult(Java.Lang.Object raw)
        {
            Exception nodeException, messageException;

            try {
                //send the message
                var nodeResult = raw.JavaCast <INodeApiGetConnectedNodesResult> ();
                foreach (var node in nodeResult.Nodes)
                {
                    WearableClass.MessageApi.SendMessage(mGoogleApiClient, node.Id, path, new byte[0]).SetResultCallback(this);                       //will go to second try/catch block
                }
                return;
            } catch (Exception e) {
                nodeException = e;
            }
            try {
                //check that it worked correctly
                var messageResult = raw.JavaCast <IMessageApiSendMessageResult> ();
                if (!messageResult.Status.IsSuccess)
                {
                    Log.Error(TAG, "Failed to connect to Google Api Client with status "
                              + messageResult.Status);
                }
                return;
            } catch (Exception e) {
                messageException = e;
            }
            //Will never get here
            Log.Warn(TAG, "Unexpected type for OnResult");
            Log.Error(TAG, "Node Exception", nodeException);
            Log.Error(TAG, "Message Exception", messageException);
        }
Пример #2
0
        //Follow the same flow as the MainActivity for the Wearable (Wearable/MainActivity has more details).
        public void OnResult(Java.Lang.Object raw)
        {
            Exception nodeException, messageException;

            try {
                var nodeResult = raw.JavaCast <INodeApiGetConnectedNodesResult> ();
                foreach (var node in nodeResult.Nodes)
                {
                    WearableClass.MessageApi.SendMessage(mGoogleApiClient, node.Id, START_ACTIVITY_PATH, new byte[0])
                    .SetResultCallback(this);
                }
                return;
            } catch (Exception e) {
                nodeException = e;
            }
            try {
                var messageResult = raw.JavaCast <IMessageApiSendMessageResult> ();
                if (!messageResult.Status.IsSuccess)
                {
                    Log.Error(TAG, "Failed to connect to Google Api Client with status "
                              + messageResult.Status);
                }
                return;
            } catch (Exception e) {
                messageException = e;
            }
            //We should never get to this point
            Log.Wtf(TAG, "Unexpected type for OnResult");
            Log.Error(TAG, "Node Exception", nodeException);
            Log.Error(TAG, "Message Exception", messageException);
        }
Пример #3
0
        public void OnResult(Java.Lang.Object result)
        {
            if (state == 0)
            {
                state = 1;
                var apiResult = result.JavaCast <INodeApiGetConnectedNodesResult> ();
                var nodes     = apiResult.Nodes;
                var phoneNode = nodes.FirstOrDefault();
                if (phoneNode == null)
                {
                    DisplayError();
                    return;
                }

                WearableClass.MessageApi.SendMessage(client, phoneNode.Id,
                                                     "/bikenow/SearchNearestStations/" + ActionStatus.ToString(),
                                                     new byte[0]).SetResultCallback(this);
            }
            else
            {
                state = 0;
                var apiResult = result.JavaCast <IMessageApiSendMessageResult> ();
                Android.Util.Log.Info("SendMessage", apiResult.RequestId.ToString());
            }
        }
Пример #4
0
        //Since Java bytecode does not support generics, casting between types can be messy. Handle everything here.
        public void OnResult(Java.Lang.Object raw)
        {
            Exception nodeException, messageException;

            try
            {
                // Get the message that was send
                var nodeResult = raw.JavaCast <INodeApiGetConnectedNodesResult>();

                // Get all of the selected Nodes
                var list        = nodeResult.Nodes.Select(x => x.DisplayName).ToList();
                var listAdapter = new ArrayAdapter <string>(
                    Context, Android.Resource.Layout.SimpleListItem1,
                    list);

                // Show the list of Nodes in the UI
                var listview = _view.FindViewById <Android.Widget.ListView>(Resource.Id.listViewConnectedDevices);
                listview.Adapter = listAdapter;

                foreach (var node in nodeResult.Nodes)
                {
                    WearableClass.MessageApi.SendMessage(_mGoogleApiClient, node.Id, path, new byte[0]).SetResultCallback(this); //will go to second try/catch block
                }
                return;
            }
            catch (Exception e)
            {
                nodeException = e;
            }
            try
            {
                //check that it worked correctly
                var messageResult = raw.JavaCast <IMessageApiSendMessageResult>();
                if (!messageResult.Status.IsSuccess)
                {
                    Log.Error(TAG, "Failed to connect to Google Api Client with status "
                              + messageResult.Status);
                }
                return;
            }
            catch (Exception e)
            {
                messageException = e;
            }
            //Will never get here
            Log.Warn(TAG, "Unexpected type for OnResult");
            Log.Error(TAG, "Node Exception", nodeException);
            Log.Error(TAG, "Message Exception", messageException);
        }
            public void OnResult(Java.Lang.Object result)
            {
                var ar = result.JavaCast <IAchievementsLoadAchievementsResult>();

                if (ar != null)
                {
                    var count = ar.Achievements.Count;

                    AchievementInfo[] achievements = new AchievementInfo[count];

                    for (int idx = 0; idx < count; idx++)
                    {
                        var item = ar.Achievements.Get(idx);
                        var ach  = item.JavaCast <IAchievement>();


                        if (ach.Type == Android.Gms.Games.Achievement.Achievement.TypeIncremental)
                        {
                            achievements[idx] = new AchievementInfo(ach.AchievementId)
                            {
                                Completion = (ach.CurrentSteps * 100 / ach.TotalSteps)
                            };
                        }
                        else
                        {
                            achievements[idx] = new AchievementInfo(ach.AchievementId)
                            {
                                Completion = ach.State == Android.Gms.Games.Achievement.Achievement.StateUnlocked ? Achievement.Completed : 0
                            };
                        }
                    }

                    _achievementInfoDelegate(achievements);
                }
            }
Пример #6
0
        void CheckIDriveApiDriveContentsResult(Java.Lang.Object result)
        {
            try
            {
                var res = result.JavaCast <IDriveApiDriveContentsResult>();
                if (res != null)
                {
                    Stream stream = null;
                    if (!res.Status.IsSuccess)
                    {
                        Debug.WriteLine("U AR A MORON! Error while trying to create new file contents");
                        return;
                    }

                    try
                    {
                        stream = res.DriveContents.OutputStream;
                        WriteDriveFile(stream, res);
                        _driveAction = DriveAction.None;
                    }
                    catch (Exception e)
                    {
                        stream = res.DriveContents.InputStream;
                        ReadDriveFile(stream);
                        _driveAction = DriveAction.None;
                    }
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine("miscast", e);
            }
        }
Пример #7
0
        public override bool OnLayoutChild(CoordinatorLayout parent, Java.Lang.Object child, int layoutDirection)
        {
            BottomNavigationView childView = child.JavaCast <BottomNavigationView>();

            this.height = childView.Height;
            return(base.OnLayoutChild(parent, child, layoutDirection));
        }
        public override void OnNestedScroll(CoordinatorLayout coordinatorLayout, Object child, View target,
            int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed)
        {
            base.OnNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);

            var floatingActionButtonChild = child.JavaCast<FloatingActionButton>();

            if (!floatingActionButtonChild.Enabled)
                return;

            if (isFabVisible && scrolledDistance >= MinimalScrollDistance)
            {
                floatingActionButtonChild.HideWithTranslateAnimation();
                scrolledDistance = 0;
                isFabVisible = false;
            }
            else if (!isFabVisible && scrolledDistance <= -MinimalScrollDistance)
            {
                floatingActionButtonChild.ShowWithTranslateAnimation();
                scrolledDistance = 0;
                isFabVisible = true;
            }

            if ((isFabVisible && dyConsumed >= 0) || (!isFabVisible && dyConsumed <= 0))
                scrolledDistance += dyConsumed;
        }
Пример #9
0
        public override void OnNestedScroll(CoordinatorLayout coordinatorLayout, Object child, View target,
                                            int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed)
        {
            base.OnNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);

            var viewChild = child.JavaCast <View>();

            if (!viewChild.Enabled)
            {
                return;
            }

            if (isBottomBarVisible && scrolledDistance >= MinimalScrollDistance)
            {
                viewChild.HideWithTranslateAnimation();
                scrolledDistance   = 0;
                isBottomBarVisible = false;
            }
            else if (!isBottomBarVisible && scrolledDistance <= -MinimalScrollDistance)
            {
                viewChild.ShowWithTranslateAnimation();
                scrolledDistance   = 0;
                isBottomBarVisible = true;
            }

            if (isBottomBarVisible && dyConsumed >= 0 || !isBottomBarVisible && dyConsumed <= 0)
            {
                scrolledDistance += dyConsumed;
            }
        }
Пример #10
0
 public void snapshot(Object snapshot)
 {
     if (snapshot != null)
     {
         _action.Invoke(snapshot.JavaCast <StorageTask.SnapshotBase>());
     }
 }
Пример #11
0
 public void OnSuccess(Java.Lang.Object result)
 {
     if (HandleSuccess != null)
     {
         HandleSuccess(result.JavaCast <TResult>());
     }
 }
Пример #12
0
 public void OnResult(Java.Lang.Object result)
 {
     if (OnResultAction != null)
     {
         OnResultAction(result.JavaCast <T>());
     }
 }
        /**
         * Update the position/characteristics of the face within the overlay.
         */
        public override void OnUpdate(Detector.Detections detections, Java.Lang.Object item)
        {
            const string barcodeMibikeNo = "http://download.jimicloud.com/webDown/mibike?no=7551008104";
            var          barcode         = item.JavaCast <Barcode>();
            var          stringValue     = barcode.DisplayValue;

            if (_parent.PreviouslyScanned)
            {
                return;
            }
            MessagingCenter.Send <GraphicBarcodeTracker, string>(this, "Barcode Scanned", stringValue);
            MessagingCenter.Send(this, "Close Scanner");
            _parent.PreviouslyScanned = true;

            //.Make(parent.MainLayout, "To start ride click Unlock. You are on PAYG", Snackbar.LengthLong)
            //.SetAction("Unlock",
            //    v => { })
            //.Show();
            //if (videoDisplayVal.Equals(stringValue) && !_previouslyScanned)
            //{
            //    //MessagingCenter.Send(this, "Close Scanner");

            //    //AView layout = FindViewById(Android.Resource.Id.Content);
            //    Snackbar
            //        .Make(parent.MainLayout, "To start ride click Unlock. You are on PAYG", Snackbar.LengthLong)
            //        .SetAction("Unlock",
            //            v => { })
            //        .Show();


            //}
        }
Пример #14
0
            public void Apply(Java.Lang.Object calendarCell)
            {
                if (calendarCell.Class.SimpleName == "CalendarMonthCell")
                {
                    return;
                }

                CalendarDayCell dayCell = calendarCell.JavaCast <CalendarDayCell> ();

                if (dayCell.CellType != CalendarCellType.Date)
                {
                    return;
                }

                this.calendar.TimeInMillis = dayCell.Date;

                if (calendar.Get(CalendarField.DayOfWeek) == Calendar.Saturday)
                {
                    dayCell.Selectable = false;
                }
                else
                {
                    dayCell.Selectable = true;
                }
            }
		public void OnResult(JavaObject result)
		{
			IPeopleLoadPeopleResult peopleData = result.JavaCast<IPeopleLoadPeopleResult>();
			List<string> names = new List<string>();

			if(peopleData.Status.StatusCode == CommonStatusCodes.Success)
			{
				PersonBuffer personBuffer = peopleData.PersonBuffer;
				try
				{
					int count = personBuffer.Count;
					for(int i = 0; i < count; i++)
					{
						IPerson person = personBuffer.Get(i).JavaCast<IPerson>();
						names.Add(person.DisplayName);
					}
					_activity.DisplayFriendNames(names);

				} finally
				{
					personBuffer.Close();
				}
			} else
			{
				Log.Error(TAG, "Error requesting visible circles: {0}", peopleData.Status);
			}
		}
Пример #16
0
        public void SetRequest(string nodeKey, object obj, Action onSuccess = null, Action <string> onError = null)
        {
            DatabaseReference dr = FirebaseDatabase.Instance.GetReference("requests");
            var req = dr.Child(nodeKey);

            if (dr != null)
            {
                if (obj != null)
                {
                    string objJsonString = JsonConvert.SerializeObject(obj);

                    Gson gson = new GsonBuilder().SetPrettyPrinting().Create();

                    HashMap dataHashMap = new HashMap();

                    Java.Lang.Object jsonObj = gson.FromJson(objJsonString, dataHashMap.Class);

                    dataHashMap = jsonObj.JavaCast <HashMap>();


                    req.SetValue(dataHashMap);
                }
                else
                {
                    req.Child("Status").SetValue("Canceled");
                }
            }
        }
Пример #17
0
        public void Apply(Java.Lang.Object p0)
        {
            if (!(p0 is CalendarDayCell))
            {
                return;
            }

            CalendarDayCell calendarCell = p0.JavaCast <CalendarDayCell>();

            if (calendarCell.CellType != CalendarCellType.Date)
            {
                return;
            }

            calendarCell.SetBackgroundColor(
                Android.Graphics.Color.ParseColor("#F8F8F8"),  // used when the cell is enabled
                Android.Graphics.Color.ParseColor("#E0E0E0")); // used when the cell is disabled

            calendarCell.SetTextColor(
                Android.Graphics.Color.ParseColor("#000000"),  // used when the cell is enabled
                Android.Graphics.Color.ParseColor("#FFFFFF")); // used when the cell is disabled

            calendar.TimeInMillis = calendarCell.Date;

            var weekDay = calendar.Get(Java.Util.CalendarField.DayOfWeek);

            if (weekDay == 1 || weekDay == 7)
            {
                calendarCell.SetBackgroundColor(
                    Android.Graphics.Color.ParseColor("#EEEEEE"),  // used when the cell is enabled
                    Android.Graphics.Color.ParseColor("#E0E0E0")); // used when the cell is disabled

                calendarCell.SetTextColor(
                    Android.Graphics.Color.ParseColor("#999999"),  // used when the cell is enabled
                    Android.Graphics.Color.ParseColor("#AAAAAA")); // used when the cell is disabled
            }

            var currentDate = Java.Util.Calendar.Instance.Get(Java.Util.CalendarField.Date);
            var currentMoth = Java.Util.Calendar.Instance.Get(Java.Util.CalendarField.Month);
            var currentYear = Java.Util.Calendar.Instance.Get(Java.Util.CalendarField.Year);

            var boldTypeface = Android.Graphics.Typeface.Create(
                calendarCell.TextPaint.Typeface, Android.Graphics.TypefaceStyle.Bold);

            if (calendar.Get(Java.Util.CalendarField.Date) == currentDate &&
                calendar.Get(Java.Util.CalendarField.Month) == currentMoth &&
                calendar.Get(Java.Util.CalendarField.Year) == currentYear)
            {
                calendarCell.BorderColor = Android.Graphics.Color.ParseColor("#00FF44");
                calendarCell.BorderWidth = global::Android.App.Application.Context.ToPixels(2);

                calendarCell.Typeface = boldTypeface;
            }

            if (calendarCell.Selected)
            {
                calendarCell.Typeface = boldTypeface;
            }
        }
        /// <summary>
        /// On Geofence Request Result
        /// </summary>
        /// <param name="result"></param>
        public void OnResult(Java.Lang.Object result)
        {
            var res = result.JavaCast <IResult>();

            int    statusCode = res.Status.StatusCode;
            string message    = string.Empty;

            switch (res.Status.StatusCode)
            {
            case Android.Gms.Location.GeofenceStatusCodes.SuccessCache:
            case Android.Gms.Location.GeofenceStatusCodes.Success:
                if (CurrentRequestType == RequestType.Add)
                {
                    message = string.Format("{0} - {1}", CrossGeofence.Id, "Successfully added Geofence.");

                    foreach (GeofenceCircularRegion region in Regions.Values)
                    {
                        CrossGeofence.GeofenceListener.OnMonitoringStarted(region.Id);
                    }
                }
                else
                {
                    message = string.Format("{0} - {1}", CrossGeofence.Id, "Geofence Update Received");
                }

                break;

            case Android.Gms.Location.GeofenceStatusCodes.Error:
                message = string.Format("{0} - {1}", CrossGeofence.Id, "Error adding Geofence.");
                break;

            case Android.Gms.Location.GeofenceStatusCodes.GeofenceTooManyGeofences:
                message = string.Format("{0} - {1}", CrossGeofence.Id, "Too many geofences.");
                break;

            case Android.Gms.Location.GeofenceStatusCodes.GeofenceTooManyPendingIntents:
                message = string.Format("{0} - {1}", CrossGeofence.Id, "Too many pending intents.");
                break;

            case Android.Gms.Location.GeofenceStatusCodes.GeofenceNotAvailable:
                message = string.Format("{0} - {1}", CrossGeofence.Id, "Geofence not available.");
                break;
            }

            System.Diagnostics.Debug.WriteLine(message);

            if (statusCode != Android.Gms.Location.GeofenceStatusCodes.Success && statusCode != Android.Gms.Location.GeofenceStatusCodes.SuccessCache && IsMonitoring)
            {
                // Rather than force killing all running geofences, delegate action on geofence failures to the application.
                // This lets the application decide to ignore the error, perform retry logic, stop monitoring as below, or any other behavior.
                // StopMonitoringAllRegions();
                ((GeofenceImplementation)CrossGeofence.Current).LocationHasError = true;

                if (!string.IsNullOrEmpty(message))
                {
                    CrossGeofence.GeofenceListener.OnError(message);
                }
            }
        }
Пример #19
0
        public override bool OnDependentViewChanged(CoordinatorLayout parent, Java.Lang.Object child, View dependency)
        {
            var view   = child.JavaCast <TextView> ();
            int offset = dependency.Top - view.Top;

            ViewCompat.OffsetTopAndBottom(view, offset);
            return(true);
        }
Пример #20
0
 private static T Get(Java.Lang.Object value)
 {
     if (value == null)
     {
         return(null);
     }
     return(value.JavaCast <T>());
 }
        public void OnResult(Java.Lang.Object result)
        {
            var h = OnResultHandler;

            if (h != null)
            {
                h(result.JavaCast <TResult> ());
            }
        }
Пример #22
0
 public void OnResponse(Java.Lang.Object parameter)
 {
     if (parameter is Java.Lang.Boolean)
     {
         var res = parameter.JavaCast <Java.Lang.Boolean>();
         isReady = res.BooleanValue();
         initializeTcs?.TrySetResult(res.BooleanValue());
     }
 }
Пример #23
0
        void IResultCallback.OnCompleted(Java.Lang.Exception exception, Java.Lang.Object s, Java.Lang.Object t)
        {
            var handler = onCompleted;

            if (handler != null)
            {
                handler(exception, s.JavaCast <S> (), t.JavaCast <T> ());
            }
        }
Пример #24
0
        void IFutureCallback.OnCompleted(Java.Lang.Exception ex, Java.Lang.Object response)
        {
            var handler = onCompleted;

            if (handler != null)
            {
                handler(ex, response.JavaCast <T> ());
            }
        }
Пример #25
0
        /// <summary>
        /// Raises the result event.
        /// </summary>
        /// <param name="result">Result object.</param>
        public void OnResult(Java.Lang.Object result)
        {
            var res = result.JavaCast <IResult>();

            int statusCode = res.Status.StatusCode;
            ////int statusCode = 0;
            string message = string.Empty;

            switch (statusCode)
            {
            case CommonStatusCodes.SuccessCache:
            case CommonStatusCodes.Success:
                if (this.CurrentRequestType == RequestType.Add)
                {
                    message = string.Format("{0} - {1}", CrossGeofence.Id, "Successfully added Geofence.");

                    foreach (GeofenceCircularRegion region in this.Regions.Values)
                    {
                        CrossGeofence.GeofenceListener.OnMonitoringStarted(region.Id);
                    }
                }
                else
                {
                    message = string.Format("{0} - {1} - {2}", CrossGeofence.Id, "Geofence Update Received", CurrentRequestType);
                }

                break;

            case CommonStatusCodes.Error:
                message = string.Format("{0} - {1}", CrossGeofence.Id, "Error adding Geofence.");
                break;

            case Android.Gms.Location.GeofenceStatusCodes.GeofenceTooManyGeofences:
                message = string.Format("{0} - {1}", CrossGeofence.Id, "Too many geofences.");
                break;

            case Android.Gms.Location.GeofenceStatusCodes.GeofenceTooManyPendingIntents:
                message = string.Format("{0} - {1}", CrossGeofence.Id, "Too many pending intents.");
                break;

            case Android.Gms.Location.GeofenceStatusCodes.GeofenceNotAvailable:
                message = string.Format("{0} - {1}", CrossGeofence.Id, "Geofence not available.");
                break;
            }

            System.Diagnostics.Debug.WriteLine(message);

            if (statusCode != CommonStatusCodes.Success && statusCode != CommonStatusCodes.SuccessCache && this.IsMonitoring)
            {
                this.StopMonitoringAllRegions();

                if (!string.IsNullOrEmpty(message))
                {
                    CrossGeofence.GeofenceListener.OnError(message);
                }
            }
        }
Пример #26
0
        public void OnSuccess(Java.Lang.Object result)
        {
            var c = HandleSuccess;

            if (c != null)
            {
                c(result.JavaCast <TResult>());
            }
        }
Пример #27
0
        protected override void OnBeforeClusterItemRendered(Java.Lang.Object item, MarkerOptions options)
        {
            var marker = item.JavaCast <ClusterMarkerOptions> ();

            options
            .SetTitle(marker.Options.Title)
            .SetSnippet(marker.Options.Snippet)
            .SetIcon(marker.Options.Icon);
        }
            public void OnSuccess(Java.Lang.Object result)
            {
                var handler = HandleSuccess;

                if (handler != null)
                {
                    handler(result.JavaCast <TResult>());
                }
            }
            public void OnResult(Java.Lang.Object result)
            {
                var dataItemResult = result.JavaCast <IDataApiDataItemResult> ();

                if (dataItemResult.Status.IsSuccess)
                {
                    OnResultAction(dataItemResult);
                }
            }
		public void OnResult(JavaObject result)
		{
			Log.Debug(TAG, "Revoke user access");
			var status = result.JavaCast<Statuses>();
			if(status.IsSuccess)
			{
				_context.RemoveGoogleAccount();
			}

		}
Пример #31
0
        public void OnSuccess(Java.Lang.Object result)
        {
            Console.WriteLine("6");
            var c = HandleSuccess;

            if (c != null)
            {
                c(result.JavaCast <TResult>());
            }
        }
Пример #32
0
        public void OnLoadFinished(Android.Support.V4.Content.Loader loader, Java.Lang.Object data)
        {
            var cursor = data.JavaCast <ICursor>();

            if (cursor != null)
            {
                _myAdapter       = new ContactAdapter(Context, cursor);
                listview.Adapter = _myAdapter;
            }
        }
Пример #33
0
        /// <summary>
        /// Destroys the item.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <param name="position">The position.</param>
        /// <param name="object">The object.</param>
        public override void DestroyItem(Android.Views.View container, int position, Java.Lang.Object @object)
        {
            //activePickerViews[position].OnDateSelected -= HandleOnDateSelected;
            //activePickerViews.Remove(position);
            var monthView = @object.JavaCast <MonthView>();

            (container.JavaCast <Android.Support.V4.View.ViewPager>()).RemoveView(monthView);
            _reusableMonthView = monthView;
            _activeMonthViews.Remove(position);
        }
        /// <summary>
        /// On Geofence Request Result
        /// </summary>
        /// <param name="result"></param>
        public void OnResult(Object result)
        {
            var res = result.JavaCast<IResult>();

            int statusCode = res.Status.StatusCode;
            string message = string.Empty;

            switch (res.Status.StatusCode)
            {
                case GeofenceStatusCodes.SuccessCache:
                case GeofenceStatusCodes.Success:
                    if(CurrentRequestType==RequestType.Add)
                    {
                        message = string.Format("{0} - {1}", CrossGeofence.Id, "Successfully added Geofence.");

                        foreach(GeofenceCircularRegion region in Regions.Values)
                        {
                            CrossGeofence.GeofenceListener.OnMonitoringStarted(region.Id);
                        }
                    }
                    else
                    {
                        message = string.Format("{0} - {1}", CrossGeofence.Id, "Geofence Update Received");
                    }

                    break;
                case GeofenceStatusCodes.Error:
                    message = string.Format("{0} - {1}", CrossGeofence.Id, "Error adding Geofence.");
                    break;
                case GeofenceStatusCodes.GeofenceTooManyGeofences:
                    message = string.Format("{0} - {1}", CrossGeofence.Id, "Too many geofences.");
                    break;
                case GeofenceStatusCodes.GeofenceTooManyPendingIntents:
                    message = string.Format("{0} - {1}", CrossGeofence.Id, "Too many pending intents.");
                    break;
                case GeofenceStatusCodes.GeofenceNotAvailable:
                    message = string.Format("{0} - {1}", CrossGeofence.Id, "Geofence not available.");
                    break;
            }

            Debug.WriteLine(message);

            if (statusCode != GeofenceStatusCodes.Success && statusCode != GeofenceStatusCodes.SuccessCache && IsMonitoring)
            {
                StopMonitoringAllRegions();

                if (!string.IsNullOrEmpty(message))
                    CrossGeofence.GeofenceListener.OnError(message);
            }
        }