Код: Выделить всё
private async void OnButtonBluetoothClicked(object sender, EventArgs e)
{
bool isBluetoothAvailable = await Bluetooth.GetAvailabilityAsync();
if (!isBluetoothAvailable)
{
await this.DisplayAlert("Error", "Bluetooth is unavailable.", "Exit");
if (Application.Current is null) throw new NullReferenceException();
Application.Current.Quit();
}
else
{
lblBluetoothSupport.Text = "Bluetooth available";
}
var devices = await Bluetooth.ScanForDevicesAsync(new RequestDeviceOptions { AcceptAllDevices = true });
lblBluetoothSupport.Text = $"Devices found: {devices.Count}";
foreach (var device in devices.ToList())
{
BluetoothDevices.Add(device);
Debug.WriteLine($"{device.Name} {device.Id} {device.Gatt}");
}
}
Похоже, это не проблема с разрешениями. Вот разрешения Android:
Код: Выделить всё
Код: Выделить всё
Подробнее здесь: https://stackoverflow.com/questions/790 ... -bluetooth