Widget Control
The widget control provides information about installing and running widget applications.
It also provides functions for the following:
- Sending update requests to the widget applications
- Retrieving details of running instances for the same package widget applications
The main features of the Tizen.Applications.WidgetControl
class includes the following:
-
For using the widget control features, you can create a widget control instance with a specific widget ID.
-
Getting information on widget applications
For the widget applications that are installed but not running, you can retrieve widget information.
-
Listening to widget lifecycle events on widget applications
For running widget applications, you can listen to widget application lifecycle events.
-
Communicating with running widget instances
For running widget instances, you can trigger an update event, send update data, and retrieve running widget instances detail.
Prerequisites
To enable your application to use the widget control functionality, follow these steps:
-
To use the methods and properties of the Tizen.Applications.WidgetControl class, include the Tizen.Applications namespace in your application:
C#Copyusing Tizen.Applications;
-
To get information on widget application, the application has to request permission by adding the following privilege to the
tizen-manifest.xml
file:XMLCopy<privileges> <privilege>http://tizen.org/privilege/widget.viewer</privilege> </privileges>
Create a widget control
Create an instance of widget control with an ID of the widget application using the Tizen.Applications.WidgetControl class:
C#
Copy
WidgetControl control = new WidgetControl(Your Widget ID);
Get information on widget applications
Get the main application ID, package ID, and available scale lists from the control:
C#
Copy
string mainId = control.MainAppId;
string packageId = control.PackageId;
IEnumerable<WidgetControl.Scale> scales = control.GetScales();
Listen to widget lifecycle events on widget applications
Add lifecycle listeners on the control to listen to widget lifecycle events:
C#
Copy
private static void OnCreated(object sender, Tizen.Applications.WidgetLifecycleEventArgs args)
{
string instanceId = args.InstanceId;
string widgetId = args.WidgetId;
/// Widget application is created
}
private static void OnDestroyed(object sender, Tizen.Applications.WidgetLifecycleEventArgs args)
{
/// Widget application is destroyed
}
private static void OnPaused(object sender, Tizen.Applications.WidgetLifecycleEventArgs args)
{
/// Widget application is paused
}
private static void OnResumed(object sender, Tizen.Applications.WidgetLifecycleEventArgs args)
{
/// Widget application is resumed
}
control.Created += OnCreated;
control.Created += OnDestroyed;
control.Created += OnPaused;
control.Created += OnResumed;
string mainId = control.MainAppId;
string packageId = control.PackageId;
IEnumerable<WidgetControl.Scale> scales = control.GetScales();
Communicate with running widget instances
To communicate with the running widget instances, follow these steps:
-
Operate on the control:
-
Get running widget instances:
C#CopyIEnumerable<WidgetControl.Instance> instances = control.GetInstances();
-
-
Operate on the instances:
-
Get details of running widget instances and send an update to the widget application:
C#Copyforeach (WidgetControl.Instance ins in instances) { /// Get widget instance content var data = ins.GetContent(); /// Change widget update period ins.ChangePeriod(2.0); /// Trigger widget update ins.ChangeContent(data, true); }
-
Related information
- Dependencies
- Tizen 4.0 and Higher