Tizen Native API
|
The Battery API provides functions to get information about the battery.
Required Header
#include <device/battery.h>
#include <device/callback.h>
Overview
The Battery API provides the way to get the current battery capacity value, battery state and charging state. It also supports the API for an application to receive the battery events from the system. To receive the battery event it should be described by the callback function.
Functions | |
int | device_battery_get_percent (int *percent) |
Gets the battery charge percentage. | |
int | device_battery_is_charging (bool *charging) |
Gets the charging state. | |
int | device_battery_get_level_status (device_battery_level_e *status) |
Gets the battery level status. |
Enumeration Type Documentation
Enumeration for the battery level status.
- Since :
- 2.3.1
- Enumerator:
Function Documentation
int device_battery_get_level_status | ( | device_battery_level_e * | status | ) |
Gets the battery level status.
- Since :
- 2.3.1
- Parameters:
-
[out] status The battery level status
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
DEVICE_ERROR_NONE Successful DEVICE_ERROR_INVALID_PARAMETER Invalid parameter DEVICE_ERROR_OPERATION_FAILED Operation failed
int device_battery_get_percent | ( | int * | percent | ) |
Gets the battery charge percentage.
It returns an integer value from 0
to 100
that indicates remaining battery charge as a percentage of the maximum level.
- Since :
- 2.3.1
- Remarks:
- In order to be notified when the battery state changes, use system_info_set_changed_cb().
- Parameters:
-
[out] percent The remaining battery charge percentage ( 0
~100
)
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
DEVICE_ERROR_NONE Successful DEVICE_ERROR_INVALID_PARAMETER Invalid parameter DEVICE_ERROR_PERMISSION_DENIED Permission denied DEVICE_ERROR_OPERATION_FAILED Operation failed
int device_battery_is_charging | ( | bool * | charging | ) |
Gets the charging state.
- Since :
- 2.3.1
- Parameters:
-
[out] charging The battery charging state
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
DEVICE_ERROR_NONE Successful DEVICE_ERROR_INVALID_PARAMETER Invalid parameter DEVICE_ERROR_OPERATION_FAILED Operation failed