Reputation: 950
I'm attempting to run a timed Background Task in a Windows Universal app. In the Background Task, I'd like get some details about the user's phone, including remaining battery charge percent. It appears that the only way to access Battery info is through the Windows.Phone
namespace, which is unavailable to a Windows Runtime component.
So far, I've tried some unconventional things, including adding a public static object
property to the Background Task class, which I'd set to a reference to the Battery, and then retrieve information from via Reflection. This fails, because the reference is invariably null at runtime.
Is there any way to get battery information in a Background Task in a Universal Windows App?
Upvotes: 1
Views: 528
Reputation: 12019
Windows Phone 8.1 supports this via the Battery
class, but there is no equivalent for Windows 8.1.
Looking forwards, Windows 10 provides a newer Battery
class that works across all devices.
Upvotes: 1