Created
December 7, 2017 17:46
-
-
Save juucustodio/fc30ee898b4e737f5c47e0953e814154 to your computer and use it in GitHub Desktop.
Example of Bluetooth in Xamarin.Forms applications - http://julianocustodio.com/bluetooth
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
private async void searchDevice(object sender, EventArgs e) | |
{ | |
if (bluetoothBLE.State == BluetoothState.Off) | |
{ | |
await DisplayAlert("Atenção", "Bluetooth desabilitado.", "OK"); | |
} | |
else | |
{ | |
list.Clear(); | |
adapter.ScanTimeout = 10000; | |
adapter.ScanMode = ScanMode.Balanced; | |
adapter.DeviceDiscovered += (obj, a) => | |
{ | |
if (!list.Contains(a.Device)) | |
list.Add(a.Device); | |
}; | |
await adapter.StartScanningForDevicesAsync(); | |
} | |
} | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment