public override void ViewDidLoad() { base.ViewDidLoad(); _networkManagerProxy = new CMPNetworkManagerSharedProxy("www.google.com"); _networkManagerProxy.NetworkStatusChanged += (object sender, CMPNetworkEventArgs e) => { Console.WriteLine(e.State); }; _networkManagerProxy.StartMonitoring(); Console.WriteLine(_networkManagerProxy.IsNetworkReachable()); // Perform any additional setup after loading the view, typically from a nib. Button.AccessibilityIdentifier = "myButton"; Button.TouchUpInside += delegate { _networkManagerProxy.StopMonitoring(); }; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); _networkManagerProxy = new CMPNetworkManagerSharedProxy(this); _networkManagerProxy.NetworkStatusChanged += (object sender, CMPNetworkEventArgs e) => { Console.WriteLine(e.State); }; _networkManagerProxy.StartMonitoring(); // Get our button from the layout resource, // and attach an event to it Button button = FindViewById <Button>(Resource.Id.myButton); button.Click += delegate { _networkManagerProxy.StopMonitoring(); }; }