Beispiel #1
0
        /// <summary>
        /// Starts observing capabilities information for changes.
        /// </summary>
        /// <remarks>
        /// Capabilities' events will be never invoked before calling this method.
        /// </remarks>
        public void StartListening()
        {
            try
            {
                SystemSettings.Data3GNetworkSettingChanged +=
                    (s, e) => { Network3GChanged?.Invoke(s, new CapabilityChangedEventArgs(e.Value)); };
            }
            catch (NotSupportedException e)
            {
                Log.Warn("SystemInfo", e.Message);
            }

            try
            {
                SystemSettings.NetworkWifiNotificationSettingChanged +=
                    (s, e) => { WifiNotificationChanged?.Invoke(s, new CapabilityChangedEventArgs(e.Value)); };
            }
            catch (NotSupportedException e)
            {
                Log.Warn("SystemInfo", e.Message);
            }

            try
            {
                SystemSettings.NetworkFlightModeSettingChanged +=
                    (s, e) => { FlightModeChanged?.Invoke(s, new CapabilityChangedEventArgs(e.Value)); };
            }
            catch (NotSupportedException e)
            {
                Log.Warn("SystemInfo", e.Message);
            }
        }
        /// <summary>
        /// Default class constructor.
        /// </summary>
        public Capability()
        {
            _service = DependencyService.Get <ICapability>();

            _service.Network3GChanged += (s, e) => { Network3GChanged?.Invoke(s, e); };

            _service.WifiNotificationChanged += (s, e) => { WifiNotificationChanged?.Invoke(s, e); };

            _service.FlightModeChanged += (s, e) => { FlightModeChanged?.Invoke(s, e); };

            _service.StartListening();
        }