BatteryStatusProvider Class
The source of the battery status of the device (https://w3c.github.io/battery/), read by navigator.getBattery(), of the browsing contexts that share a BrowsingContextOptions (BatteryStatusOptions.Provider). The default implementation returns BatteryStatusProvider.Status, set by the application (e.g. to simulate a battery). Override BatteryStatusProvider.GetStatus to read another source, and call BatteryStatusProvider.OnStatusChanged when the status changes, to update the BatteryManager objects of the documents.
public class BatteryStatusProviderRemarks
A provider can be shared by several browsing contexts, and used from any thread.
Constructors
| Name | Description |
|---|---|
| BatteryStatusProvider() |
BatteryStatusProvider()
BatteryStatus.cspublic BatteryStatusProvider()No documentation is available.
Properties
| Name | Description |
|---|---|
| Status | Gets or sets the status returned by the default implementation of BatteryStatusProvider.GetStatus (BatteryStatus.Default by default). Setting it updates the BatteryManager objects of the documents, which fire their change events. |
Status
BatteryStatus.csGets or sets the status returned by the default implementation of BatteryStatusProvider.GetStatus (BatteryStatus.Default by default). Setting it updates the BatteryManager objects of the documents, which fire their change events.
public BatteryStatus Status { get; set; }Property value
Methods
| Name | Description |
|---|---|
| GetStatus() | Returns the status of the battery. The default implementation returns BatteryStatusProvider.Status. It is called on the thread of an event loop, and must not block it. |
| OnStatusChanged() | Raises BatteryStatusProvider.StatusChanged, then reads the status again for the BatteryManager objects of the documents, which fire their change events. It can be called from any thread. |
GetStatus()
BatteryStatus.csReturns the status of the battery. The default implementation returns BatteryStatusProvider.Status. It is called on the thread of an event loop, and must not block it.
public virtual BatteryStatus GetStatus()Returns
OnStatusChanged()
BatteryStatus.csRaises BatteryStatusProvider.StatusChanged, then reads the status again for the BatteryManager objects of the documents, which fire their change events. It can be called from any thread.
protected void OnStatusChanged()Events
| Name | Description |
|---|---|
| StatusChanged | Raised when the status changes (BatteryStatusProvider.OnStatusChanged). |
StatusChanged
Raised when the status changes (BatteryStatusProvider.OnStatusChanged).
public event EventHandler? StatusChanged