public void Stop()
        {
            if (_broadcastReceiver == null)
            {
                throw new InvalidOperationException(
                          "Network status monitoring not active.");
            }

            // Unregister the receiver so we no longer get updates.
            Application.Context.UnregisterReceiver(_broadcastReceiver);

            // Set the variable to nil, so that we know the receiver is no longer used.
            _broadcastReceiver.ConnectionStatusChanged -= OnNetworkStatusChanged;
            _broadcastReceiver = null;
        }
        public void Start()
        {
            if (_broadcastReceiver != null)
            {
                throw new InvalidOperationException(
                          "Network status monitoring already active.");
            }

            // Create the broadcast receiver and bind the event handler
            // so that the app gets updates of the network connectivity status
            _broadcastReceiver = new NetStatBroadcastReceiver();
            _broadcastReceiver.ConnectionStatusChanged += OnNetworkStatusChanged;

            // Register the broadcast receiver
            Application.Context.RegisterReceiver(_broadcastReceiver,
                                                 new IntentFilter(ConnectivityManager.ConnectivityAction));
        }