Event
The application can broadcast its own events to all listeners, and subscribe to events. The events can be either predefined system events from the platform (only platform modules can broadcast system events) or user-defined events (broadcast by UI and service applications).
The main features of the Event API are:
- Event publication
To publish an event, use the event_publish_app_event() and event_publish_trusted_app_event() functions. The event_publish_trusted_app_event() function publishes a trusted event which can only be received by the application that has the same signature as the publishing application.
- Event subscription
To subscribe to an event, use the event_add_event_handler() function. When no longer needed, unsubscribe the event with the event_remove_event_handler() function.
- Launch-On-Events
Service applications can be launched when a desired target event occurs.
To register an interest in a Launch-On-Event, define the http://tizen.org/appcontrol/operation/launch_on_event operation in the tizen-manifest.xml file.
The following table shows the system events that support Launch-On-Event.
Table: System events supporting Launch-On-Event Name Condition tizen.system.event.battery_charger_status When the charger state is "connected". tizen.system.event.usb_status When the USB state is "connected". tizen.system.event.earjack_status When the earjack status is "connected". tizen.system.event.incoming_msg When the msg_type and msg_id exist.
The application can be suspended while in the background, causing a pause in event handling. Since the application cannot receive events in the suspended state, they are all delivered in series after the application exits the suspended state. Consider how to manage this situation and prevent the application from being flooded with events:
- To handle events in the background without going to a suspended state, declare a background category.
- To avoid receiving any events that are triggered while the application is suspended, remove the event handler before entering the suspended state and add it back after exiting the suspended state. You can manage the event handler addition and removal in the APP_EVENT_SUSPENDED_STATE_CHANGED event callback, which is triggered each time the application enters and exist the suspended state.
The following table lists the platform event types.
Module | Category | Event name | Event data | Condition | Notes | |||
---|---|---|---|---|---|---|---|---|
Key | Value | |||||||
capi-system-device | battery | tizen.system.event.battery_charger_status | battery_charger_status |
|
When the charger has been connected or disconnected, or when the charging state has changed (charging or not). | If there is an earlier occurrence regarding this event, you receive the event as soon as you register an event handler for this event. You can use this earlier event data as the initial value. | ||
tizen.system.event.battery_level_status | battery_level_status |
|
When the battery level has changed. | You can get the current value with the device_battery_get_level_status() function. | ||||
deviced | usb | tizen.system.event.usb_status | usb_status |
|
When the USB cable has been connected or disconnected, or when the USB service state has changed. | You can get the current value with the RUNTIME_INFO_KEY_USB_CONNECTED key. | ||
earjack | tizen.system.event.earjack_status | earjack_status |
|
When the earjack connection state has changed. | You can get the current value with the RUNTIME_INFO_KEY_AUDIO_JACK_STATUS key. | |||
display | tizen.system.event.display_state | display_state |
|
When the display state has changed. | You can get the current value with the device_display_get_state() function. | |||
systemd | system | tizen.system.event.boot_completed | N/A | N/A | When platform booting has been completed. | You can treat the initial value as false before you receive this event. If the application is already in a boot-completed state before you register an event handler, you receive the event as soon as you register the event handler. | ||
tizen.system.event.system_shutdown | N/A | N/A | When the system power-off has been started. | You can treat the initial value as false before you receive this event. If the application is already in a shutting-down state before you register an event handler, you receive the event as soon as you register the event handler. | ||||
resourced | ram memory | tizen.system.event.low_memory | low_memory |
|
When the size of available memory has changed. | If there is an earlier occurrence regarding this event, you receive the event as soon as you register an event handler for this event. You can use this earlier event data as the initial value. | ||
network | connectivity | tizen.system.event.wifi_state | wifi_state |
|
When the Wi-Fi state has changed. | You can get the current value with the connection_get_wifi_state() function. | ||
tizen.system.event.bt_state | bt_state |
|
When the Bluetooth state has changed. | You can get the current value with the bt_adapter_get_state() function. | ||||
bt_le_state |
|
When Bluetooth LE state has changed. | ||||||
bt_transfering_state |
|
When the file transfer state has changed. | ||||||
libslp-location | location | tizen.system.event.location_enable_state | location_enable_state |
|
When the location-enable_state has been changed, for example, by the user toggling the location setting in the settings menu or quick panel. | You can get the current value with the location_manager_is_enabled_method() function. | ||
tizen.system.event.gps_enable_state | gps_enable_state |
|
When the gps-enable_state has changed. | You can get the current value with the location_manager_is_enabled_method() function. | ||||
tizen.system.event.nps_enable_state | nps_enable_state |
|
When the NPS setting has been changed, for example, by the user toggling the location settings. | You can get the current value with the location_manager_is_enabled_method() function. | ||||
msg-service | message | tizen.system.event.incoming_msg | msg_type |
|
When an SMS, push, or CB message has been received. | |||
msg_id | msg_id: Message ID of the received message (string of the unsigned int type value) | |||||||
alarm-manager | time | tizen.system.event.time_changed | N/A | N/A | When the system time setting has changed. | You can get the current value with the alarm_get_current_time() function. | ||
setting | time | tizen.system.event.time_zone | time_zone | The value of this key is the time zone value of the time zone database, for example, "Asia/Seoul", "America/New_York". For more information, see the IANA Time Zone Database. | When the time zone has changed. | You can get the current value with the SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE key. | ||
locale | tizen.system.event.hour_format | hour_format |
|
When the hour_format has changed, for example, by the user toggling the date and time settings for the 24-hour clock (where OFF stands for the 12-hour clock). | You can get the current value with the SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR key. | |||
tizen.system.event.language_set | language_set | The value of this key is full name of locale, for example, ko_KR.UTF8 in case of Korean and en_US.UTF8 in case of American English. For more information, see the Linux locale information. | When the language_set has changed. | You can get the current value with the SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE key. | ||||
tizen.system.event.region_format | region_format | The value of this key is the full name of the locale, for example, ko_KR.UTF8 in case of the Korean region format and en_US.UTF8 in case of the USA region format. For more information, see the Linux locale information. | When the region format has changed. | You can get the current value with the SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY key. | ||||
sound | tizen.system.event.silent_mode | silent_mode |
|
When the ringtone has been changed to 0 or another mode. For example, if the call slider has been changed to 0, silent_mode is "on". Otherwise, silent_mode is "off". | You can get the current value with the SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE key. | |||
vibration | tizen.system.event.vibration_state | vibration_state |
|
When the vibration state has changed. | You can get the current value with the RUNTIME_INFO_KEY_VIBRATION_ENABLED key. | |||
screen | tizen.system.event.screen_autorotate_state | screen_autorotate_state |
|
When the screen_autorotate_state has been changed, for example, by the user toggling the display settings. | You can get the current value with the SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO key. | |||
mobile | tizen.system.event.mobile_data_state | mobile_data_state |
|
When the mobile_data_state has been changed, for example, by the user toggling the network settings. | You can get the current value with the SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED key. | |||
tizen.system.event.data_roaming_state | data_roaming_state |
|
When the data_roaming_state has been changed, for example, by the user toggling the network settings. | You can get the current value with the RUNTIME_INFO_KEY_DATA_ROAMING_ENABLED key. | ||||
font | tizen.system.event.font_set | font_set | The value of this key is the font name of the string type by font-config. | When the font has changed. | You can get the current value with the SYSTEM_SETTINGS_KEY_FONT_TYPE key. |