locked
[UWP][C#] Nullable Aggregate Battery Information RRS feed

  • Question

  • Hello,

    In my UWP application I am trying to get an Aggregate Battery Information like this:

    var aggBattery = Windows.Devices.Power.Battery.AggregateBattery;
            BatteryReport report = aggBattery.GetReport();
            aggBattery.ReportUpdated += AggBattery_ReportUpdated;
            int? fullCapacity = report.FullChargeCapacityInMilliwattHours;
            int? remainingCapacity = report.RemainingCapacityInMilliwattHours;

    Unfortunately, it seems like the current battery controller does not fit the Microsoft's one (it's CHUWI 12" tablet), and it returns null values (like in MSDN describes: https://msdn.microsoft.com/en-us/windows/uwp/devices-sensors/get-battery-info). The only Charging/Discharging info is real.

    How can I get get the battery information in this case (I mean charging percentage)?


    • Edited by David_FF Wednesday, December 21, 2016 2:11 PM title tag
    Sunday, December 18, 2016 11:09 AM

All replies

  • Hi leozel,

    I could not reproduce your issue on my device. Maybe you could use individual BatteryReport instead. Or you may provide feedback to CHUWI to see wheter they could provide battery info for the device. And I will help you report this issue. If there is any update, I will post it here.
    https://msdn.microsoft.com/en-us/windows/uwp/devices-sensors/get-battery-info

    async private void RequestIndividualBatteryReports()
    {
        // Find batteries 
        var deviceInfo = await DeviceInformation.FindAllAsync(Battery.GetDeviceSelector());
        foreach(DeviceInformation device in deviceInfo)
        {
            try
            {
            // Create battery object
            var battery = await Battery.FromIdAsync(device.Id);
    
            // Get report
            var report = battery.GetReport();
    
            // get info
            }
            catch { /* Add error handling, as applicable */ }
        }
    }
    Best Regards,
    David

     

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    • Edited by David_FF Wednesday, December 21, 2016 12:58 PM
    Monday, December 19, 2016 10:04 AM
  • Hi David,

    Unfortunately not - I tried your code too, it does not give any positive result.

    All the values are null, only the battery status Charging/Discharging is working properly.

    Best Regards,

    leozel

    Thursday, December 22, 2016 6:31 PM
  • Hi leozel,

    I have already reported this issue. Thanks for your feedback. 

    Best Regards,
    David


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, December 23, 2016 11:56 AM