@@ -9,13 +9,19 @@ A widget displays brief information about an application on the UI of another ap
Basic concepts:
- Widget provider
The widget provider is an atomic service that provides the content to be displayed. It controls the display content, component layout, and component click events of a widget.
- Widget host
The widget host is an application that displays the widget content and controls the position where the widget is displayed in the host application.
- Widget Manager
The Widget Manager is a resident agent that manages widgets added to the system and provides functions such as periodic widget update.
> The widget host and provider do not keep running all the time. The Widget Manager starts the widget provider to obtain widget information when a widget is added, deleted, or updated.
You only need to develop widget content as the widget provider. The system automatically handles the work done by the widget host and Widget Manager.
...
...
@@ -244,13 +250,14 @@ You should override **onDestroy** to delete widget data.
}
```
For details about the persistence method, see [Lightweight Data Store Development](../database/database-preference-guidelines.md).
For details about the persistence method, see [Lightweight Data Store Development](../database/database-storage-guidelines.md).
Note that the **Want** passed by the widget host to the widget provider contains a temporary flag, indicating whether the requested widget is a temporary one.
Normal widget: a widget that will be persistently used by the widget host
- Normal widget: a widget that will be persistently used by the widget host
- Temporary widget: a widget that is temporarily used by the widget host
Temporary widget: a widget that is temporarily used by the widget host
Data of a temporary widget is not persistently stored. If the widget framework is killed and restarted, data of a temporary widget will be deleted. However, the widget provider is not notified of which widget is deleted, and still keeps the data. Therefore, the widget provider should implement data clearing. In addition, the widget host may convert a temporary widget into a normal one. If the conversion is successful, the widget provider should process the widget ID and store the data persistently. This prevents the widget provider from deleting persistent data when clearing temporary widgets.
...
...
@@ -258,6 +265,7 @@ Data of a temporary widget is not persistently stored. If the widget framework i
You can use HML, CSS, and JSON to develop the UI page for a JavaScript-programmed widget.
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...
...
@@ -17,18 +18,18 @@ You must extend **AbilityContext** to implement this module.
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Implements the context that provides the capabilities and APIs of **FormExtension**. This class is inherited from **ExtensionContext**.
...
...
@@ -15,11 +15,11 @@ Updates a widget. This method uses a callback to return the result.
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...
...
@@ -17,10 +17,10 @@ Starts an ability. This API uses a callback to return the result.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-featureAbility.md#Want) | Yes| Information about the ability to start, such as the ability name and bundle name.|
| callback | AsyncCallback<void> | No| Callback used to return the result indicating whether the API is successfully called.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-featureAbility.md#Want) | Yes| Information about the ability to start, such as the ability name and bundle name.|
| callback | AsyncCallback<void> | No| Callback used to return the result indicating whether the API is successfully called.|
**Example**
...
...
@@ -45,15 +45,15 @@ Starts an ability. This API uses a promise to return the result.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-featureAbility.md#Want) | Yes| Information about the ability to start, such as the ability name and bundle name.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-featureAbility.md#Want) | Yes| Information about the ability to start, such as the ability name and bundle name.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return the result indicating whether the API is successfully called.|
| Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return the result indicating whether the API is successfully called.|
**Example**
...
...
@@ -80,9 +80,9 @@ Terminates this ability. This API uses a callback to return the result.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<void> | No| Callback used to return the result indicating whether the API is successfully called.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<void> | No| Callback used to return the result indicating whether the API is successfully called.|
**Example**
...
...
@@ -103,9 +103,9 @@ Terminates this ability. This API uses a promise to return the result.
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return the result indicating whether the API is successfully called.|
| Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return the result indicating whether the API is successfully called.|
**Example**
...
...
@@ -128,16 +128,16 @@ Connects this ability to a Service ability.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-featureAbility.md#Want) | Yes| Information about the ability to connect to, such as the ability name and bundle name.|
| options | [ConnectOptions](#connectoptions) | Yes| Callback used to return the information indicating that the connection is successful, interrupted, or failed.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-featureAbility.md#Want) | Yes| Information about the ability to connect to, such as the ability name and bundle name.|
| options | [ConnectOptions](#connectoptions) | Yes| Callback used to return the information indicating that the connection is successful, interrupted, or failed.|
**Return value**
| Type| Description|
| -------- | -------- |
| number | A number, based on which the connection will be interrupted.|
| Type| Description|
| -------- | -------- |
| number | A number, based on which the connection will be interrupted.|
**Example**
...
...
@@ -165,10 +165,10 @@ Disconnects this ability from the Service ability. This API uses a callback to r
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| connection | number | Yes| Number returned after **connectAbility** is called.|
| callback | AsyncCallback<void> | No| Callback used to return the result indicating whether the API is successfully called.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| connection | number | Yes| Number returned after **connectAbility** is called.|
| callback | AsyncCallback<void> | No| Callback used to return the result indicating whether the API is successfully called.|
**Example**
...
...
@@ -189,16 +189,16 @@ Disconnects this ability from the Service ability. This API uses a promise to re
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| connection | number | Yes| Number returned after **connectAbility** is called.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| connection | number | Yes| Number returned after **connectAbility** is called.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return the result indicating whether the API is successfully called.|
| Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return the result indicating whether the API is successfully called.|
**Example**
```js
...
...
@@ -216,8 +216,8 @@ Defines the **ConnectOptions** data structure.