Languages

Menu
Sites
Language
how to get the battery event

Hi

I want to get Battery event like a state of charging.

Please let me know how to achieve it.

Thanks in advance.

Responses

2 Replies
Alex Dem

Hi,
To monitor battery state changes you could use this api:  https://developer.tizen.org/dev-guide/2.3.0/org.tizen.native.mobile.apireference/group__CAPI__SYSTEM__DEVICE__CALLBACK__MODULE.html
You should register callback as it described here: https://developer.tizen.org/dev-guide/2.3.0/org.tizen.tutorials/html/native/system/device_tutorial_n.htm#changes

You coul look at this tutorial also (how to retrive battery information):
https://developer.tizen.org/dev-guide/2.3.0/org.tizen.tutorials/html/native/system/device_tutorial_n.htm#battery
Alexey.

Jean Yang

Hi, 

Just share you a simple example: 

1.regisist call back in main()

result = device_add_callback(DEVICE_CALLBACK_BATTERY_CHARGING, battery_charging_cb, NULL);

2.implement the call back

static void battery_charging_cb(device_callback_e type, void *value, void *user_data)
 {
    int val;
    val = (int) value;
     dlog_print(DLOG_ERROR, "tag", "battery_charging_cb - %d", val);

    
 }

3.insert and remove the usb charger, you will see the call back will be called, also value was changed.