Tizen Native API  3.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
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]typeThe device type to monitor
[out]valueThe changed value
[out]user_dataThe user data passed from the callback registration function

Enumeration Type Documentation

Enumeration for the device state callback.

Since :
2.3
Enumerator:
DEVICE_CALLBACK_BATTERY_CAPACITY 

Called when a battery charge percentage is changed

DEVICE_CALLBACK_BATTERY_LEVEL 

Called when a battery level is changed

DEVICE_CALLBACK_BATTERY_CHARGING 

Called when battery charging state is changed

DEVICE_CALLBACK_DISPLAY_STATE 

Called when a display state is changed

DEVICE_CALLBACK_FLASH_BRIGHTNESS 

Called when a flash brightness is changed (Since Tizen )


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
Parameters:
[in]typeThe device type to monitor
[in]callbackThe callback function to add
[in]user_dataThe user data to be passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
DEVICE_ERROR_NONESuccessful
DEVICE_ERROR_INVALID_PARAMETERInvalid parameter
DEVICE_ERROR_ALREADY_IN_PROGRESSOperation already
DEVICE_ERROR_OPERATION_FAILEDOperation failed

Removes a device callback function.

Since :
2.3
Parameters:
[in]typeThe device type to monitor
[in]callbackThe callback function to remove
Returns:
0 on success, otherwise a negative error value
Return values:
DEVICE_ERROR_NONESuccessful
DEVICE_ERROR_INVALID_PARAMETERInvalid parameter
DEVICE_ERROR_OPERATION_FAILEDOperation failed