PowerManager
PowerManager
PowerManager
PowerManager
Class
Definition
Provides access to information about a device's battery and power supply status.
public : static class PowerManagerpublic static class PowerManagerPublic Static Class PowerManager// You can use this class in JavaScript.
- Attributes
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
Properties
BatteryStatus BatteryStatus BatteryStatus BatteryStatus
Gets the device's battery status.
public : static BatteryStatus BatteryStatus { get; }public static BatteryStatus BatteryStatus { get; }Public Static ReadOnly Property BatteryStatus As BatteryStatus// You can use this property in JavaScript.
The device's battery status.
EnergySaverStatus EnergySaverStatus EnergySaverStatus EnergySaverStatus
Gets the devices's battery saver status, indicating when to save energy.
public : static EnergySaverStatus EnergySaverStatus { get; }public static EnergySaverStatus EnergySaverStatus { get; }Public Static ReadOnly Property EnergySaverStatus As EnergySaverStatus// You can use this property in JavaScript.
The status of battery saver.
Remarks
A user can turn on battery saver at any time to save energy (as long as the device is running on battery power). Battery saver extends battery life by limiting background activity on the device. In addition to the efforts of battery saver, your app can do its own part to save energy. Before initiating resource intensive tasks, check EnergySaverStatus to make sure battery saver isn’t on. If your app’s resource intensive tasks are long-running, listen for the EnergySaverStatusChanged event so that those tasks can be stopped when battery saver is turned on.
A user can also set battery saver to turn on automatically when the battery reaches a specified charge threshold, such as 20% remaining. When it's in this state (before it turns on automatically), EnergySaverStatus is Off. If the user disables this automatic setting, EnergySaverStatus is Disabled.
Even if the automatic setting is enabled, when the device is plugged in, battery saver is turned off and EnergySaverStatus is Disabled. It is not Off because as long as the device is plugged in, battery saver cannot be turned on.
When battery saver is on, the receipt of push notifications is disabled to save energy. But there are a couple exceptions to this. Battery saver settings (from the Settings app) provides settings that allow your app to receive push notifications even when battery saver is on. If your app depends heavily on push notifications, we recommend notifying users that they may not receive notifications while battery saver is on and to make it easy for them to adjust battery saver settings. For more info and examples, see Windows Push Notification Services (WNS) overview.
PowerSupplyStatus PowerSupplyStatus PowerSupplyStatus PowerSupplyStatus
Gets the device's power supply status.
public : static PowerSupplyStatus PowerSupplyStatus { get; }public static PowerSupplyStatus PowerSupplyStatus { get; }Public Static ReadOnly Property PowerSupplyStatus As PowerSupplyStatus// You can use this property in JavaScript.
The device's power supply status.
RemainingChargePercent RemainingChargePercent RemainingChargePercent RemainingChargePercent
Gets the total percentage of charge remaining from all batteries connected to the device.
public : static int RemainingChargePercent { get; }public static int RemainingChargePercent { get; }Public Static ReadOnly Property RemainingChargePercent As int// You can use this property in JavaScript.
- Value
- int int int int
The total percentage of charge remaining from all batteries connected to the device.
RemainingDischargeTime RemainingDischargeTime RemainingDischargeTime RemainingDischargeTime
Gets the total runtime remaining from all batteries connected to the device.
public : static TimeSpan RemainingDischargeTime { get; }public static TimeSpan RemainingDischargeTime { get; }Public Static ReadOnly Property RemainingDischargeTime As TimeSpan// You can use this property in JavaScript.
- Value
- TimeSpan TimeSpan TimeSpan TimeSpan
The total runtime remaining from all batteries connected to the device.
Events
BatteryStatusChanged BatteryStatusChanged BatteryStatusChanged BatteryStatusChanged
Occurs when BatteryStatus changes.
public : static event EventHandler BatteryStatusChanged<object>public static event EventHandler BatteryStatusChanged<object>Public Static Event BatteryStatusChanged<object>// You can use this event in JavaScript.
EnergySaverStatusChanged EnergySaverStatusChanged EnergySaverStatusChanged EnergySaverStatusChanged
Occurs when EnergySaverStatus changes.
public : static event EventHandler EnergySaverStatusChanged<object>public static event EventHandler EnergySaverStatusChanged<object>Public Static Event EnergySaverStatusChanged<object>// You can use this event in JavaScript.
PowerSupplyStatusChanged PowerSupplyStatusChanged PowerSupplyStatusChanged PowerSupplyStatusChanged
Occurs when the PowerSupplyStatus changes.
public : static event EventHandler PowerSupplyStatusChanged<object>public static event EventHandler PowerSupplyStatusChanged<object>Public Static Event PowerSupplyStatusChanged<object>// You can use this event in JavaScript.
RemainingChargePercentChanged RemainingChargePercentChanged RemainingChargePercentChanged RemainingChargePercentChanged
Occurs when RemainingChargePercent changes.
public : static event EventHandler RemainingChargePercentChanged<object>public static event EventHandler RemainingChargePercentChanged<object>Public Static Event RemainingChargePercentChanged<object>// You can use this event in JavaScript.
RemainingDischargeTimeChanged RemainingDischargeTimeChanged RemainingDischargeTimeChanged RemainingDischargeTimeChanged
Occurs when RemainingDischargeTime changes.
public : static event EventHandler RemainingDischargeTimeChanged<object>public static event EventHandler RemainingDischargeTimeChanged<object>Public Static Event RemainingDischargeTimeChanged<object>// You can use this event in JavaScript.