How to add system event listener to detect that vibration mode was ON/OFF
By Alex Dem
06 Apr 2016 11:00
void extract_bundle_keyval_cb(const char *key, const int type, const bundle_keyval_t *kv, void *user_data)
{
if(BUNDLE_TYPE_STR == type && strcmp(key,EVENT_KEY_VIBRATION_STATE) == 0 )
{
void *val;
size_t size;
bundle_keyval_get_basic_val((bundle_keyval_t *)kv, &val, &size);
if (strncmp(val,EVENT_VAL_VIBRATION_ON,size-1) == 0)
{
dlog_print(DLOG_INFO, LOG_TAG, "Vibrarion mode is on");
}
else if (strncmp(val,EVENT_VAL_VIBRATION_OFF,size-1) == 0)
{
dlog_print(DLOG_INFO, LOG_TAG, "Vibrarion mode is off");
}
}
}
void vibration_state_event_cb(const char *event_name, bundle *event_data, void *user_data)
{
bundle_foreach (event_data, extract_bundle_keyval_cb, NULL);
}
//...
{
//...
event_handler_h handler;
event_add_event_handler(SYSTEM_EVENT_VIBRATION_STATE,
(event_cb)vibration_state_event_cb, NULL, &handler);
//...
}
You must log in to use this service. Log in now?
The tag you entered already exists.
Do you want to report this post as spam?
The post has been reported as spam.
cannot be empty.
Are you sure you want to cancel and return to the list?
The code has been copied to the clipboard.
Enter a title.
Enter a description.