protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.ActivityMain); beacons = new List <Beacon>(); listView = FindViewById <ListView>(Resource.Id.lv_beacons); adapter = new BeaconAdapter(this, Resource.Layout.BeaconItem, beacons); listView.Adapter = adapter; scanningStatus = FindViewById <TextView>(Resource.Id.tv_status); scanToggle = FindViewById <Switch>(Resource.Id.swtScan); scanToggle.CheckedChange += scanToggle_CheckedChange; beaconReceiver = new BeaconReceiver(this); serviceStatusReceiver = new ServiceStatusReceiver(this); beaconReceiver.ActionReceived += beaconReceiver_ActionReceived; beaconReceiver.BeaconExpired += beaconExpirationReceiver_ActionReceived; serviceStatusReceiver.StatusReceived += serviceStatusReceiver_StatusReceived; BeaconServiceController.StartBeaconService(this, 20000, 60000, 7000, 5000, null); }
private void scanToggle_CheckedChange(object sender, CompoundButton.CheckedChangeEventArgs e) { if (e.IsChecked) { // Start the service. BeaconServiceController.StartBeaconService(this, 20000, 60000, 5000, 5000, null); } else { // Stop the service. BeaconServiceController.StopBeaconService(this); } }