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:

Prerequisites

To enable your application to use the widget control functionality, follow these steps:

  1. To use the methods and properties of the Tizen.Applications.WidgetControl class, include the Tizen.Applications namespace in your application:

    C#
    Copy
    using Tizen.Applications;
  2. To get information on widget application, the application has to request permission by adding the following privilege to the tizen-manifest.xml file:

    XML
    Copy
    <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:

  1. Operate on the control:

    • Get running widget instances:

      C#
      Copy
      IEnumerable<WidgetControl.Instance> instances = control.GetInstances();
  2. Operate on the instances:

    • Get details of running widget instances and send an update to the widget application:

      C#
      Copy
      foreach (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); }
  • Dependencies
    • Tizen 4.0 and Higher
Package Manager
Next Widget Viewer
Submit your feedback to GitHub