Widget Service
The Widget Service API provides functionality to get the information of installed widgets.
The main features of the Widget Service API include:
-
Retrieving information of widgets
You can retrieve the information of an installed widget application.
-
Communicating with running widget instances
You can communicate with running widget instances.
NoteThis API will work only if the widget and application are packaged together.
Prerequisites
-
To use the Widget Service API (in mobile and wearable applications), the application has to request permission by adding the following privilege to the
tizen-manifest.xml
file:<privileges> <privilege>http://tizen.org/privilege/widget.viewer</privilege> </privileges>
-
To use the functions of the Widget Service API, include the
<widget_service.h>
header file in your application:#include <widget_service.h>
Retrieve the information
Widget Service API provides functions to get the information about widget related properties.
-
Gets the pixel size of given size type:
int ret; int w; int h; ret = widget_service_get_size(WIDGET_SIZE_TYPE_2x2, &w, &h);
-
Gets the supported list of sizes:
int ret; int cnt = 20; int *w; int *h; ret = widget_service_get_supported_sizes("pkg_id", &cnt, &w, &h);
-
Gets the ID of a widget by the given ID of package or UI app:
char *id; int result; id = widget_service_get_widget_id("pkg_id");
Communicate with widget instances
Widget Service API provides functions to trigger the event that changes the state of the widget.
-
Triggers the update event for a given widget instance:
int ret; int force = 0; Bundle data; data = bundle_create(); ret = widget_service_trigger_update("widget_id", "instance_id", data, force);
-
Changes the update period of the given widget instance:
int ret; ret = widget_service_change_period("widget_id", "instance_id", 1.0);
-
Gets and Sets the disabled state of a widget:
void _widget_disable_event_cb(const char *widget_id, bool is_disabled, void *user_data) { }
int ret; bool is_disabled = true; ret = widget_service_get_widget_disabled(SAMPLE_PKGNAME, &is_disabled); ret = widget_service_set_disable_event_cb(_widget_disable_event_cb, NULL); ret = widget_service_set_widget_disabled("widget_id", true);
Note
‘widget_service_set_widget_disabled’ is not for use by third-party applications.
Related information
- Dependencies
- Tizen 2.4 and Higher for Mobile
- Tizen 2.3.1 and Higher for Wearable