Example #1
0
 public void Start()
 {
     if (context == null)
     {
         throw new Exception("Context not set.");
     }
     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 NetworkStatusBroadcastReceiver();
     _broadcastReceiver.ConnectionStatusChanged += OnNetworkStatusChanged;
     // Register the broadcast receiver
     context.RegisterReceiver(_broadcastReceiver,
                              new IntentFilter(ConnectivityManager.ConnectivityAction));
 }