Table of Contents

Class BatteryManager

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The BatteryManager interface of the {{domxref("Battery Status API", "", "", "nocode")}} provides information about the system's battery charge level. The GetBattery() method returns a promise that resolves with a BatteryManager interface.

[Value("BatteryManager")]
public class BatteryManager : EventTarget
Inheritance
BatteryManager
Inherited Members

Remarks

Since Chrome 103, the BatteryManager interface of {{domxref("Battery Status API", "", "", "nocode")}} only expose to secure context.

-The {{domxref("Battery Status API", "", "", "nocode")}}
-GetBattery()

See also on MDN

Constructors

BatteryManager()

public BatteryManager()

Properties

Charging

The charging read-only property of the BatteryManager interface is a Boolean value indicating whether or not the device's battery is currently being charged. When its value changes, the BatteryManagerchargingchange event is fired.

[Value("charging")]
public bool Charging { get; }

Property Value

bool

A boolean.

Remarks

If the battery is charging or the user agent is unable to report the battery status information, this value is true. Otherwise, it is false.

-BatteryManager
-GetBattery()

See also on MDN

ChargingTime

The chargingTime read-only property of the BatteryManager interface indicates the amount of time, in seconds, that remain until the battery is fully charged, or 0 if the battery is already fully charged or the user agent is unable to report the battery status information.
If the battery is currently discharging, its value is GlobalObject.Infinity.
When its value changes, the BatteryManagerchargingtimechange event is fired.

[Value("chargingTime")]
public double ChargingTime { get; }

Property Value

double

A number.

Remarks

NOTE

Even if the time returned is precise to the second,
browsers round them to a higher interval
(typically to the closest 15 minutes) for privacy reasons.

-BatteryManager
-GetBattery()

See also on MDN

DischargingTime

The dischargingTime read-only property of the BatteryManager interface indicates the amount of time, in seconds, that remains until the battery is fully discharged,
or GlobalObject.Infinity if the battery is currently charging rather than discharging or the user agent is unable to report the battery status information.
When its value changes, the BatteryManagerdischargingtimechange event is fired.

[Value("dischargingTime")]
public double DischargingTime { get; }

Property Value

double

A number.

Remarks

NOTE

Even if the time returned is precise to the second, browsers round them to a higher
interval (typically to the closest 15 minutes) for privacy reasons.

-BatteryManager
-GetBattery()

See also on MDN

Level

The level read-only property of the BatteryManager interface indicates the current battery charge level as a value between 0.0 and 1.0.
A value of 0.0 means the battery is empty and the system is about to be suspended.
A value of 1.0 means the battery is full or the user agent is unable to report the battery status information.
When its value changes, the BatteryManagerlevelchange event is fired.

[Value("level")]
public Number Level { get; }

Property Value

Number

A number.

Remarks

Onchargingchange

[Value("onchargingchange")]
public EventHandlerNonNull Onchargingchange { get; set; }

Property Value

EventHandlerNonNull

Onchargingtimechange

[Value("onchargingtimechange")]
public EventHandlerNonNull Onchargingtimechange { get; set; }

Property Value

EventHandlerNonNull

Ondischargingtimechange

[Value("ondischargingtimechange")]
public EventHandlerNonNull Ondischargingtimechange { get; set; }

Property Value

EventHandlerNonNull

Onlevelchange

[Value("onlevelchange")]
public EventHandlerNonNull Onlevelchange { get; set; }

Property Value

EventHandlerNonNull