public void ProcessIntent(Context context, Intent intent) { if (intent.Action == BluetoothDevice.ActionAclConnected) { BluetoothDevice bd = (BluetoothDevice)intent.Extras.Get("android.bluetooth.device.extra.DEVICE"); //TODO: update with better wording if (SettingsProcessor.IsDeviceSelectedForNotifications(bd.Name, bd.Address, context)) { string foo = bd.Name + " " + bd.Address; SendMessage(" connected " + foo); } } if (intent.Action == BluetoothDevice.ActionAclDisconnectRequested || intent.Action == BluetoothDevice.ActionAclDisconnected) { BluetoothDevice bd = (BluetoothDevice)intent.Extras.Get("android.bluetooth.device.extra.DEVICE"); //TODO: update with better wording if (SettingsProcessor.IsDeviceSelectedForNotifications(bd.Name, bd.Address, context)) { string foo = bd.Name + " " + bd.Address; SendMessage(" disconnected " + foo); } } }
protected void onButtonClick() { ListView deviceView = FindViewById <ListView> (Resource.Id.deviceListView); DeviceListAdapter deviceListAdapter = deviceView.Adapter as DeviceListAdapter; SettingsProcessor.StoreSelections(deviceListAdapter.GetSelectedDevices(), this.ApplicationContext); this.Finish(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Get our button from the layout resource, // and attach an event to it Button button = FindViewById <Button> (Resource.Id.saveButton); button.Click += delegate { onButtonClick(); }; StartService(new Intent(this, typeof(BluetoothLowEnergySearchService))); List <string> availableDevices = (new BluetoothProcessor()).GetDeviceList(this); List <DeviceInfo> bluetoothDevices = SettingsProcessor.RetrievePreviousSelections(availableDevices, this.ApplicationContext); ListView deviceView = FindViewById <ListView> (Resource.Id.deviceListView); deviceView.Adapter = new DeviceListAdapter(this, bluetoothDevices); }