未验证 提交 735fa1f5 编写于 作者: O openharmony_ci 提交者: Gitee

!9137 翻译完成:7847+8654+8922 [新增特性]卡片分享doc

Merge pull request !9137 from wusongqing/TR7847
......@@ -96,10 +96,27 @@ Enumerates the widget parameters.
| Name | Value | Description |
| ----------- | ---- | ------------ |
| IDENTITY_KEY | "ohos.extra.param.key.form_identity" | ID of a widget.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| IDENTITY_KEY<sup>9+</sup> | "ohos.extra.param.key.form_identity" | ID of a widget.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| DIMENSION_KEY | "ohos.extra.param.key.form_dimension" | Widget dimension. |
| NAME_KEY | "ohos.extra.param.key.form_name" | Widget name. |
| MODULE_NAME_KEY | "ohos.extra.param.key.module_name" | Name of the module to which the widget belongs. |
| WIDTH_KEY | "ohos.extra.param.key.form_width" | Widget width. |
| HEIGHT_KEY | "ohos.extra.param.key.form_height" | Widget height. |
| TEMPORARY_KEY | "ohos.extra.param.key.form_temporary" | Temporary widget. |
| ABILITY_NAME_KEY<sup>9+</sup> | "ohos.extra.param.key.ability_name" | Ability name. |
| DEVICE_ID_KEY<sup>9+</sup> | "ohos.extra.param.key.device_id" | Device ID.<br>This is a system API. |
| BUNDLE_NAME_KEY<sup>9+</sup> | "ohos.extra.param.key.bundle_name" | Key that specifies the target bundle name.<br>This is a system API. |
## FormDimension
Enumerates the widget dimensions.
**System capability**: SystemCapability.Ability.Form
| Name | Value | Description |
| ----------- | ---- | ------------ |
| Dimension_1_2<sup>9+</sup> | 1 | 1 x 2. |
| Dimension_2_2<sup>9+</sup> | 2 | 2 x 2. |
| Dimension_2_4<sup>9+</sup> | 3 | 2 x 4. |
| Dimension_4_4<sup>9+</sup> | 4 | 4 x 4. |
| Dimension_2_1<sup>9+</sup> | 5 | 2 x 1. |
......@@ -28,16 +28,16 @@ SystemCapability.Ability.Form
| ----------- | ---- | ------------ |
| ERR_COMMON | 1 | Default error code. |
| ERR_PERMISSION_DENY | 2 | No permission to perform the operation. |
| ERR_GET_INFO_FAILED | 4 | Failed to query widget information. |
| ERR_GET_BUNDLE_FAILED | 5 | Failed to query the bundle information. |
| ERR_GET_LAYOUT_FAILED | 6 | Failed to query the layout information. |
| ERR_GET_INFO_FAILED | 4 | Failed to obtain the widget information. |
| ERR_GET_BUNDLE_FAILED | 5 | Failed to obtain the bundle information. |
| ERR_GET_LAYOUT_FAILED | 6 | Failed to obtain the layout information. |
| ERR_ADD_INVALID_PARAM | 7 | Invalid parameter. |
| ERR_CFG_NOT_MATCH_ID | 8 | The widget ID does not match. |
| ERR_CFG_NOT_MATCH_ID | 8 | The widget ID does not match any widget. |
| ERR_NOT_EXIST_ID | 9 | The widget ID does not exist. |
| ERR_BIND_PROVIDER_FAILED | 10 | Failed to bind to the widget provider. |
| ERR_MAX_SYSTEM_FORMS | 11 | The number of system widgets exceeds the upper limit. |
| ERR_MAX_INSTANCES_PER_FORM | 12 | The number of instances per widget exceeds the upper limit. |
| ERR_OPERATION_FORM_NOT_SELF | 13 | The application is not allowed to operate widgets applied by other applications. |
| ERR_OPERATION_FORM_NOT_SELF | 13 | The application is not allowed to operate widgets provided by other applications. |
| ERR_PROVIDER_DEL_FAIL | 14 | The widget provider failed to delete the widget. |
| ERR_MAX_FORMS_PER_CLIENT | 15 | The number of widgets applied for by the widget host exceeds the upper limit. |
| ERR_MAX_SYSTEM_TEMP_FORMS | 16 | The number of temporary widgets exceeds the upper limit. |
......@@ -48,3 +48,4 @@ SystemCapability.Ability.Form
| ERR_SYSTEM_RESPONSES_FAILED | 30 | The system service failed to respond. |
| ERR_FORM_DUPLICATE_ADDED | 31 | The widget has been added. |
| ERR_IN_RECOVERY | 36 | Failed to overwrite the widget data. |
| ERR_DISTRIBUTED_SCHEDULE_FAILED<sup>9+</sup> | 37 | The distributed scheduler failed.<br>This is a system API. |
......@@ -4,7 +4,8 @@ The **FormHost** module provides APIs related to the widget host, which is an ap
> **NOTE**
>
> 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.
> 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.
> The APIs of this module are system APIs and cannot be called by third-party applications.
## Modules to Import
......@@ -28,13 +29,11 @@ Deletes a widget. This API uses an asynchronous callback to return the result. A
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
| formId | string | Yes | Widget ID.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
......@@ -58,19 +57,17 @@ Deletes a widget. This API uses a promise to return the result. After this API i
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
| formId | string | Yes | Widget ID.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
| Promise&lt;void&gt; | Promise used to return the result.|
**Parameters**
......@@ -93,13 +90,11 @@ Releases a widget. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
| formId | string | Yes | Widget ID.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
......@@ -123,13 +118,11 @@ Releases a widget. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| -------------- | ------ | ---- | ----------- |
| formId | string | Yes | ID of a widget. |
| formId | string | Yes | Widget ID. |
| isReleaseCache | boolean | Yes | Whether to release the cache.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
......@@ -154,20 +147,18 @@ Releases a widget. This API uses a promise to return the result. After this API
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| -------------- | ------ | ---- | ----------- |
| formId | string | Yes | ID of a widget. |
| formId | string | Yes | Widget ID. |
| isReleaseCache | boolean | No | Whether to release the cache.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
......@@ -190,13 +181,11 @@ Requests a widget update. This API uses an asynchronous callback to return the r
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
| formId | string | Yes | Widget ID.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
......@@ -220,19 +209,17 @@ Requests a widget update. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
| formId | string | Yes | Widget ID.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
......@@ -255,13 +242,11 @@ Converts a temporary widget to a normal one. This API uses an asynchronous callb
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
| formId | string | Yes | Widget ID.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
......@@ -285,19 +270,17 @@ Converts a temporary widget to a normal one. This API uses a promise to return t
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
| formId | string | Yes | Widget ID.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
......@@ -320,8 +303,6 @@ Instructs the widget framework to make a widget visible. This API uses an asynch
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
......@@ -350,8 +331,6 @@ Instructs the widget framework to make a widget visible. This API uses a promise
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
......@@ -362,7 +341,7 @@ Instructs the widget framework to make a widget visible. This API uses a promise
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
......@@ -385,8 +364,6 @@ Instructs the widget framework to make a widget invisible. This API uses an asyn
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
......@@ -415,8 +392,6 @@ Instructs the widget framework to make a widget invisible. This API uses a promi
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
......@@ -427,7 +402,7 @@ Instructs the widget framework to make a widget invisible. This API uses a promi
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
......@@ -450,8 +425,6 @@ Instructs the widget framework to make a widget updatable. This API uses an asyn
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
......@@ -480,8 +453,6 @@ Instructs the widget framework to make a widget updatable. This API uses a promi
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
......@@ -492,7 +463,7 @@ Instructs the widget framework to make a widget updatable. This API uses a promi
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
......@@ -515,8 +486,6 @@ Instructs the widget framework to make a widget not updatable. This API uses an
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
......@@ -545,8 +514,6 @@ Instructs the widget framework to make a widget not updatable. This API uses a p
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
......@@ -557,7 +524,7 @@ Instructs the widget framework to make a widget not updatable. This API uses a p
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
......@@ -578,8 +545,6 @@ Checks whether the system is ready. This API uses an asynchronous callback to re
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
......@@ -605,13 +570,11 @@ Checks whether the system is ready. This API uses a promise to return the result
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
......@@ -634,8 +597,6 @@ Obtains the widget information provided by all applications on the device. This
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
......@@ -665,8 +626,6 @@ Obtains the widget information provided by all applications on the device. This
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Return value**
| Type | Description |
......@@ -694,8 +653,6 @@ Obtains the widget information provided by a given application on the device. Th
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
......@@ -726,8 +683,6 @@ Obtains the widget information provided by a given application on the device. Th
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
......@@ -759,8 +714,6 @@ Obtains the widget information provided by a given application on the device. Th
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
......@@ -794,8 +747,6 @@ Deletes invalid widgets from the list. This API uses an asynchronous callback to
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
......@@ -826,8 +777,6 @@ Deletes invalid widgets from the list. This API uses a promise to return the res
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
......@@ -861,8 +810,6 @@ Obtains the widget state. This API uses an asynchronous callback to return the r
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
......@@ -902,8 +849,6 @@ Obtains the widget state. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
......@@ -944,8 +889,6 @@ Subscribes to widget uninstall events.
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
......@@ -970,8 +913,6 @@ Unsubscribes from widget uninstall events.
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
......@@ -998,8 +939,6 @@ Instructs the widgets to make themselves visible. This API uses an asynchronous
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
......@@ -1029,8 +968,6 @@ Instructs the widgets to make themselves visible. This API uses a promise to ret
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
......@@ -1042,7 +979,7 @@ Instructs the widgets to make themselves visible. This API uses a promise to ret
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
......@@ -1065,8 +1002,6 @@ Instructs the widgets to enable or disable updates. This API uses an asynchronou
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
......@@ -1096,8 +1031,6 @@ Instructs the widgets to enable or disable updates. This API uses a promise to r
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
......@@ -1109,7 +1042,7 @@ Instructs the widgets to enable or disable updates. This API uses a promise to r
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
......@@ -1121,3 +1054,71 @@ Instructs the widgets to enable or disable updates. This API uses a promise to r
console.log('formHost notifyFormsEnableUpdate, error:' + JSON.stringify(error));
});
```
## shareForm<sup>9+</sup>
shareForm(formId: string, deviceId: string, callback: AsyncCallback&lt;void&gt;): void;
Shares a specified widget with a remote device. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permissions**: ohos.permission.REQUIRE_FORM
**System capability**: SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | Widget ID.|
| deviceId | string | Yes | Remote device ID.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
```js
var formId = "12400633174999288";
var deviceId = "EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2";
formHost.shareForm(formId, deviceId, (error, data) => {
if (error.code) {
console.log('formHost shareForm, error:' + JSON.stringify(error));
}
});
```
## shareForm<sup>9+</sup>
shareForm(formId: string, deviceId: string): Promise&lt;void&gt;;
Shares a specified widget with a remote device. This API uses a promise to return the result.
This is a system API.
**Required permissions**: ohos.permission.REQUIRE_FORM
**System capability**: SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | Widget ID.|
| deviceId | string | Yes | Remote device ID.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Parameters**
```js
var formId = "12400633174999288";
var deviceId = "EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2";
formHost.shareForm(formId, deviceId).then(() => {
console.log('formHost shareForm success');
}).catch((error) => {
console.log('formHost shareForm, error:' + JSON.stringify(error));
});
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册