Пример #1
0
        /// <summary>
        /// Callback for location state changes.  Called when the location service connects or disconnects
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        private void onStateChange(object sender, LocationStateEventArgs e)
        {
            string t = "";

            // notify user... lets see how picky this is first
        }
Пример #2
0
        public override void OnReceive(Context context, Intent intent)
        {
            Bundle intentBundle = intent.Extras;

            if (intentBundle != null)
            {
                // Values
                double?lat = null;
                double?lon = null;
                double?alt = null;
                double?acc = null;

                double   temp;
                DateTime lastSent;

                Log.Debug(TAG, "Update Received");

                if (Double.TryParse(intentBundle.GetString(AppUtil.LAT_KEY), out temp))
                {
                    lat = temp;
                }
                if (Double.TryParse(intentBundle.GetString(AppUtil.LON_KEY), out temp))
                {
                    lon = temp;
                }
                if (Double.TryParse(intentBundle.GetString(AppUtil.ALT_KEY), out temp))
                {
                    alt = temp;
                }
                if (Double.TryParse(intentBundle.GetString(AppUtil.ACC_KEY), out temp))
                {
                    acc = temp;
                }
                if (!DateTime.TryParse(intentBundle.GetString(AppUtil.LAST_SENT_KEY), out lastSent))
                {
                    lastSent = DateTime.MinValue;
                }

                // Creating event args
                LocationEventArgs arg = null;

                if (intent.Action == AppUtil.LOCATION_UPDATE_ACTION)
                {
                    arg = new LocationEventArgs(lat, lon, alt, acc);

                    try
                    {
                        locationUpdate(this, arg);
                    }
                    catch (NullReferenceException e)
                    {
                        // This exception occurs when nothign is subscribed to this event, it can be safely ignored
                        Log.Debug(TAG, "Nothing is subscribed to the event");
                    }
                }
                else if (intent.Action == AppUtil.LOCATION_LAST_SENT_ACTION)
                {
                    arg = new LocationEventArgs(lastSent);

                    try
                    {
                        SendUpdate(this, arg);
                    }
                    catch (NullReferenceException e)
                    {
                        // This exception occurs when nothign is subscribed to this event, it can be safely ignored
                        Log.Debug(TAG, "Nothing is subscribed to the event");
                    }
                }
                else if (intent.Action == AppUtil.LOCATION__CONNECT_ACTION)
                {
                    LocationStateEventArgs stateArg = new LocationStateEventArgs(true);
                    ConnectionStateChange(this, stateArg);
                }
                else if (intent.Action == AppUtil.LOCATION__DISCONNECT_ACTION)
                {
                    LocationStateEventArgs stateArg = new LocationStateEventArgs(false);
                    ConnectionStateChange(this, stateArg);
                }
            }
        }