我正在尝试使用 UWP 应用程序读取我的 air pods pro 电池寿命,但Exception from HRESULT: 0xD0000033
在没有更多信息的情况下出现奇怪的异常错误。您可以在下面找到来源:
private async Task GetBLDevices()
{
DeviceInformationCollection ConnectedBluetoothDevices = await DeviceInformation.FindAllAsync(
BluetoothDevice.GetDeviceSelectorFromConnectionStatus(BluetoothConnectionStatus.Connected));
if (ConnectedBluetoothDevices == null || ConnectedBluetoothDevices.Count == 0)
return;
foreach (DeviceInformation connectedDevice in ConnectedBluetoothDevices)
{
if (connectedDevice.Name == "AirPods Pro")
GetBatteryReport(connectedDevice.Id);
}
}
private async void GetBatteryReport(string deviceId)
{
try
{
// Create aggregate battery object
var aggBattery = await Battery.FromIdAsync(deviceId);
// Get report
var report = aggBattery.GetReport();
}
catch (Exception ex)
{
}
}