Last active
December 7, 2017 17:50
-
-
Save juucustodio/86779e17375d056496042dd894ab99b7 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 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