Definition
- Namespace:
- Tizen.System
- Assembly:
- Tizen.System.dll
- API Level:
- 3
The Battery class provides the properties and events for the device battery.
public static class Battery
- Inheritance
-
Properties
View Source
IsCharging
Gets the current charging state.
Declaration
public static bool IsCharging { get; }
Property Value
API Level: 3
Declaration
public static BatteryLevelStatus Level { get; }
Property Value
API Level: 3
View Source
Percent
Gets the battery charge percentage.
Declaration
public static int Percent { get; }
Property Value
Type |
Description |
Int32 |
It returns an integer value from 0 to 100 that indicates the remaining
battery charge as a percentage of the maximum level.
|
API Level: 3
Events
View Source
ChargingStateChanged
ChargingStatusChanged is triggered when the battery charging status is changed.
This event is triggered when the charger is connected/disconnected.
Declaration
public static event EventHandler<BatteryChargingStateChangedEventArgs> ChargingStateChanged
Event Type
Examples
public static async Task BatteryEventHandler()
{
EventHandler<BatteryChargingStateChangedEventArgs> handler = null;
handler = (object sender, BatteryChargingStateChangedEventArgs args) =>
{
Console.WriteLine("battery Level is: {0}", args.IsCharging);
}
Battery.ChargingStateChanged += handler;
await Task.Delay(20000);
}
API Level: 3
View Source
LevelChanged
LevelChanged is triggered when the battery level is changed.
Declaration
public static event EventHandler<BatteryLevelChangedEventArgs> LevelChanged
Event Type
Examples
public static async Task BatteryEventHandler()
{
EventHandler<BatteryLevelChangedEventArgs> handler = null;
handler = (object sender, BatteryLevelChangedEventArgs args) =>
{
Console.WriteLine("battery Level is: {0}", args.Level);
}
Battery.LevelChanged += handler;
await Task.Delay(20000);
}
API Level: 3
View Source
PercentChanged
CapacityChanged is triggered when the battery charge percentage is changed.
Declaration
public static event EventHandler<BatteryPercentChangedEventArgs> PercentChanged
Event Type
Examples
public static async Task BatteryEventHandler()
{
EventHandler<BatteryPercentChangedEventArgs> handler = null;
handler = (object sender, BatteryChargingStateChangedEventArgs args) =>
{
Console.WriteLine("battery Percent is: {0}", args.Percent);
}
Battery.PercentChanged += handler;
await Task.Delay(20000);
}
API Level: 3