private void DoDiscoveryUnpaired() { try { this.KillDiscoverReceiver(); this.unBondedDevices.Clear(); if (BluetoothAdapter.DefaultAdapter == null) { this.DiscoveryComplete?.Invoke(this, false); return; } this.discoverReceiver = new UnboundDeviceDiscoveryReceiver( this.deviceType, this.RaiseDeviceDiscovered, this.unBondedDevices); this.GetContext().RegisterReceiver( this.discoverReceiver, new IntentFilter(BluetoothDevice.ActionFound)); BluetoothAdapter.DefaultAdapter.StartDiscovery(); this.StartAutoEnd(); } catch (Exception e) { this.log.Exception(9999, "", e); } }
private void KillDiscoverReceiver() { if (this.discoverReceiver != null) { this.GetContext().UnregisterReceiver(this.discoverReceiver); this.discoverReceiver.Dispose(); this.discoverReceiver = null; } }