【发布时间】:2021-09-22 05:32:19
【问题描述】:
我的目标是验证设备是否有蓝牙,如果有,则验证蓝牙是打开还是关闭。为此,我使用以下代码 sn-p。
public async Task<bool> GetBluetoothStatusAsync()
{
var allRadio = await Radio.GetRadiosAsync();
if (allRadio == null) return false;
var bluetoothRadio = allRadio.FirstOrDefault(radio => radio.Kind == RadioKind.Bluetooth);
return bluetoothRadio != null && bluetoothRadio.State == RadioState.On;
}
从桌面 Win32 应用程序调用时它不起作用。 如果目标平台设置为 x64,Windows.Devices.Radios 可以正常工作,但对于 x86,则无法正常工作。从windows git issues 看来,这是一个已知问题,但尚未解决。是否有解决此问题的方法?
【问题讨论】:
标签: c# windows bluetooth bluetooth-lowenergy desktop-application