Skip to content

Instantly share code, notes, and snippets.

@juucustodio
Last active December 7, 2017 17:50
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/86779e17375d056496042dd894ab99b7 to your computer and use it in GitHub Desktop.
Save juucustodio/86779e17375d056496042dd894ab99b7 to your computer and use it in GitHub Desktop.
Example of Bluetooth in Xamarin.Forms applications - http://julianocustodio.com/bluetooth
...
private async void DevicesList_OnItemSelected(object sender, SelectedItemChangedEventArgs e)
{
device = DevicesList.SelectedItem as IDevice;
var result = await DisplayAlert("AVISO", "Deseja se conectar a esse dispositivo?", "Conectar", "Cancelar");
if (!result)
return;
//Stop Scanner
await adapter.StopScanningForDevicesAsync();
try
{
await adapter.ConnectToDeviceAsync(device);
await DisplayAlert("Conectado", "Status:" + device.State , "OK");
}
catch (DeviceConnectionException ex)
{
await DisplayAlert("Erro", ex.Message, "OK");
}
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment