Answer the question
In order to leave comments, you need to log in
Any options to get battery level of bluetooth headphones (C#, Delphi)?
Good afternoon.
I would like to write a utility to show the battery level of bluetooth headphones. I looked at UWP, there are the necessary APIs for working with bluetooth and battery power, but this does not work with bluetooth headphones. I do like this:
var devices = await DeviceInformation.FindAllAsync(
BluetoothDevice.GetDeviceSelectorFromConnectionStatus(BluetoothConnectionStatus.Connected));
foreach (DeviceInformation device in devices)
{
try
{
// Create battery object
var battery = await Battery.FromIdAsync(device.Id); - тут происходит исключение
// Get report
var report = battery.GetReport();
// Update UI
//AddReportUI(BatteryReportPanel, report, battery.DeviceId);
ListBoxItemcColllections.Add(report.Status.ToString());
}
catch(Exception e)
{
ErrorTextInfo = e.Message;
}
}
Battery.FromIdAsync is used to get a Battery object that represents an individual battery controller connected to the device. However, bluetooth Id does not represent a battery controller. And currently there is no such api that could use to get bluetooth battery level.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question