Skip to content

Instantly share code, notes, and snippets.

@juucustodio
Created December 7, 2017 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juucustodio/fc30ee898b4e737f5c47e0953e814154 to your computer and use it in GitHub Desktop.
Save juucustodio/fc30ee898b4e737f5c47e0953e814154 to your computer and use it in GitHub Desktop.
Example of Bluetooth in Xamarin.Forms applications - http://julianocustodio.com/bluetooth
...
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