Tizen Native API
7.0
|
The Callback API provides functions to observe the changing of device state.
Required Header
#include <device/callback.h>
Overview
The Callback API provides the way to observe the changing of device state.
This API allows observing of the following events:
- Battery capacity
- Battery level
- Battery charging
- Display state
- Flash led state
Functions | |
int | device_add_callback (device_callback_e type, device_changed_cb callback, void *user_data) |
Adds a callback to the observing device state. | |
int | device_remove_callback (device_callback_e type, device_changed_cb callback) |
Removes a device callback function. | |
Typedefs | |
typedef void(* | device_changed_cb )(device_callback_e type, void *value, void *user_data) |
Called when a device status is changed. |
Typedef Documentation
typedef void(* device_changed_cb)(device_callback_e type, void *value, void *user_data) |
Called when a device status is changed.
Each device callback has a different output param type.
So you need to check below output param before using this function.
callback enum output type
DEVICE_CALLBACK_BATTERY_CAPACITY int
DEVICE_CALLBACK_BATTERY_LEVEL int
DEVICE_CALLBACK_BATTERY_CHARGING bool
DEVICE_CALLBACK_DISPLAY_STATE int
DEVICE_CALLBACK_FLASH_BRIGHTNESS int
- Since :
- 2.3.1
- Remarks:
- DEVICE_CALLBACK_FLASH_BRIGHTNESS callback invoked when user set flash brightness by using device_flash_set_brightness(). It does not work by camera flash operation. To register DEVICE_CALLBACK_FLASH_BRIGHTNESS callback, you need to declare the LED privilege (http://tizen.org/privilege/led).
- Parameters:
-
[out] type The device type to monitor [out] value The changed value [out] user_data The user data passed from the callback registration function
Enumeration Type Documentation
enum device_callback_e |
Enumeration for the device state callback.
- Since :
- 2.3.1
- Enumerator:
Function Documentation
int device_add_callback | ( | device_callback_e | type, |
device_changed_cb | callback, | ||
void * | user_data | ||
) |
Adds a callback to the observing device state.
- Since :
- 2.3.1
- Remarks:
- The following feature should be supported for DEVICE_CALLBACK_DISPLAY_STATE: http://tizen.org/feature/display. Otherwise DEVICE_ERROR_NOT_SUPPORTED is returned.
- Parameters:
-
[in] type The device type to monitor [in] callback The callback function to add [in] user_data The user data to be passed to the callback function
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
DEVICE_ERROR_NONE Successful DEVICE_ERROR_INVALID_PARAMETER Invalid parameter DEVICE_ERROR_ALREADY_IN_PROGRESS Operation already DEVICE_ERROR_OPERATION_FAILED Operation failed DEVICE_ERROR_NOT_SUPPORTED Not supported device
int device_remove_callback | ( | device_callback_e | type, |
device_changed_cb | callback | ||
) |
Removes a device callback function.
- Since :
- 2.3.1
- Remarks:
- The following feature should be supported for DEVICE_CALLBACK_DISPLAY_STATE: http://tizen.org/feature/display. Otherwise DEVICE_ERROR_NOT_SUPPORTED is returned.
- Parameters:
-
[in] type The device type to monitor [in] callback The callback function to remove
- 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 DEVICE_ERROR_NOT_SUPPORTED Not supported device