“689f2a01e68c0033f59055dd816ff27dc51f9dcc”上不存在“README.md”
未验证 提交 16a9f23f 编写于 作者: O openharmony_ci 提交者: Gitee

!4219 翻译完成:3689 Want统一整改

Merge pull request !4219 from wusongqing/TR3689
# AbilityDelegator
> **Note**
> **NOTE**<br/>
>
> 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.
......@@ -423,7 +423,7 @@ Starts an ability. This API uses an asynchronous callback to return the result.
| Name | Type | Mandatory| Description |
| -------- | -------------------------------------- | ---- | ------------------ |
| want | [Want](js-apis-featureAbility.md#Want) | Yes | **Want** parameter for starting the ability. |
| want | [Want](js-apis-application-Want.md) | Yes | **Want** parameter for starting the ability. |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example**
......@@ -455,7 +455,7 @@ Starts an ability. This API uses a promise to return the result.
| Name| Type | Mandatory| Description |
| ------ | -------------------------------------- | ---- | --------------- |
| want | [Want](js-apis-featureAbility.md#Want) | Yes | **Want** parameter for starting the ability.|
| want | [Want](js-apis-application-Want.md) | Yes | **Want** parameter for starting the ability.|
**Return value**
......
# FormExtension
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> 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.
Provides **FormExtension** APIs.
......@@ -35,7 +35,7 @@ Called to notify the widget provider that a **Form** instance (widget) has been
| Name| Type | Mandatory| Description |
| ------ | -------------------------------------- | ---- | ------------------------------------------------------------ |
| want | [Want](js-apis-featureAbility.md#want) | Yes | Information related to the extension, including the widget ID, name, and style. The information must be managed as persistent data to facilitate subsequent widget update and deletion.|
| want | [Want](js-apis-application-Want.md) | Yes | Information related to the extension, including the widget ID, name, and style. The information must be managed as persistent data to facilitate subsequent widget update and deletion.|
**Return value**
......
# FormHost
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> 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.
Provides APIs related to the widget host.
......@@ -23,24 +23,24 @@ deleteForm(formId: string, callback: AsyncCallback&lt;void&gt;): void;
Deletes a widget. This API uses an asynchronous callback to return the result. After this API is called, the application can no longer use the widget, and the Widget Manager will not retain the widget information.
**System capability**:
**System capability**
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
```js
var formId = "12400633174999288";
formHost.deleteForm(formId, (error, data) => {
if (error) {
console.log('formHost deleteForm, error:' + error.code);
if (error.code) {
console.log('formHost deleteForm, error:' + JSON.stringify(error));
}
});
```
......@@ -51,7 +51,7 @@ deleteForm(formId: string): Promise&lt;void&gt;;
Deletes a widget. This API uses a promise to return the result. After this API is called, the application can no longer use the widget, and the Widget Manager will not retain the widget information.
**System capability**:
**System capability**
SystemCapability.Ability.Form
......@@ -71,8 +71,10 @@ SystemCapability.Ability.Form
```js
var formId = "12400633174999288";
formHost.deleteForm(formId).catch((error) => {
console.log('formProvider deleteForm, error:' + JSON.stringify(error));
formHost.deleteForm(formId).then(() => {
console.log('formHost deleteForm success');
}).catch((error) => {
console.log('formHost deleteForm, error:' + JSON.stringify(error));
});
```
......@@ -82,24 +84,24 @@ releaseForm(formId: string, callback: AsyncCallback&lt;void&gt;): void;
Releases a widget. This API uses an asynchronous callback to return the result. After this API is called, the application can no longer use the widget, but the Widget Manager still retains the widget cache and storage information.
**System capability**:
**System capability**
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
```js
var formId = "12400633174999288";
formHost.releaseForm(formId, (error, data) => {
if (error) {
console.log('formHost releaseForm, error:' + error.code);
if (error.code) {
console.log('formHost releaseForm, error:' + JSON.stringify(error));
}
});
```
......@@ -108,27 +110,27 @@ SystemCapability.Ability.Form
releaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback&lt;void&gt;): void;
Releases a widget. This API uses an asynchronous callback to return the result. After this API is called, the application can no longer use the widget, but the Widget Manager retains the storage information about the widget and determines whether to retain the cache information based on the setting.
Releases a widget. This API uses an asynchronous callback to return the result. After this API is called, the application can no longer use the widget, but the Widget Manager retains the storage information about the widget and retains or releases the cache information based on the setting.
**System capability**:
**System capability**
SystemCapability.Ability.Form
**Parameters**
| Name | Type | Mandatory| Description |
| -------------- | ------ | ---- | ----------- |
| formId | string | Yes | ID of a widget. |
| isReleaseCache | boolean | Yes | Whether to release the cache.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
| Name | Type | Mandatory| Description |
| -------------- | ------ | ---- | ----------- |
| formId | string | Yes | ID of a widget. |
| isReleaseCache | boolean | Yes | Whether to release the cache.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
```js
var formId = "12400633174999288";
formHost.releaseForm(formId, true, (error, data) => {
if (error) {
console.log('formHost releaseForm, error:' + error.code);
if (error.code) {
console.log('formHost releaseForm, error:' + JSON.stringify(error));
}
});
```
......@@ -137,9 +139,9 @@ SystemCapability.Ability.Form
releaseForm(formId: string, isReleaseCache?: boolean): Promise&lt;void&gt;;
Releases a widget. This API uses a promise to return the result. After this API is called, the application can no longer use the widget, but the Widget Manager retains the storage information about the widget and determines whether to retain the cache information based on the setting.
Releases a widget. This API uses a promise to return the result. After this API is called, the application can no longer use the widget, but the Widget Manager retains the storage information about the widget and retains or releases the cache information based on the setting.
**System capability**:
**System capability**
SystemCapability.Ability.Form
......@@ -160,8 +162,10 @@ SystemCapability.Ability.Form
```js
var formId = "12400633174999288";
formHost.releaseForm(formId, true).catch((error) => {
console.log('formProvider releaseForm, error:' + JSON.stringify(error));
formHost.releaseForm(formId, true).then(() => {
console.log('formHost releaseForm success');
}).catch((error) => {
console.log('formHost releaseForm, error:' + JSON.stringify(error));
});
```
......@@ -177,18 +181,18 @@ SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
```js
var formId = "12400633174999288";
formHost.requestForm(formId, (error, data) => {
if (error) {
console.log('formHost requestForm, error:' + error.code);
if (error.code) {
console.log('formHost requestForm, error:' + JSON.stringify(error));
}
});
```
......@@ -219,8 +223,10 @@ SystemCapability.Ability.Form
```js
var formId = "12400633174999288";
formHost.requestForm(formId).catch((error) => {
console.log('formProvider requestForm, error:' + JSON.stringify(error));
formHost.requestForm(formId).then(() => {
console.log('formHost requestForm success');
}).catch((error) => {
console.log('formHost requestForm, error:' + JSON.stringify(error));
});
```
......@@ -230,24 +236,24 @@ castTempForm(formId: string, callback: AsyncCallback&lt;void&gt;): void;
Converts a temporary widget to a normal one. This API uses an asynchronous callback to return the result.
**System capability**:
**System capability**
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
```js
var formId = "12400633174999288";
formHost.castTempForm(formId, (error, data) => {
if (error) {
console.log('formHost castTempForm, error:' + error.code);
if (error.code) {
console.log('formHost castTempForm, error:' + JSON.stringify(error));
}
});
```
......@@ -258,7 +264,7 @@ castTempForm(formId: string): Promise&lt;void&gt;;
Converts a temporary widget to a normal one. This API uses a promise to return the result.
**System capability**:
**System capability**
SystemCapability.Ability.Form
......@@ -278,54 +284,56 @@ SystemCapability.Ability.Form
```js
var formId = "12400633174999288";
formHost.castTempForm(formId).catch((error) => {
console.log('formProvider castTempForm, error:' + JSON.stringify(error));
formHost.castTempForm(formId).then(() => {
console.log('formHost castTempForm success');
}).catch((error) => {
console.log('formHost castTempForm, error:' + JSON.stringify(error));
});
```
## notifyVisibleForms
notifyVisibleForms(formId: string, callback: AsyncCallback&lt;void&gt;): void;
notifyVisibleForms(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;void&gt;): void;
Instructs the widget framework to make a widget visible. This API uses an asynchronous callback to return the result. After this API is called, **onVisibilityChange** is invoked to notify the widget provider.
**System capability**:
**System capability**
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formIds | Array&lt;string&gt; | Yes | List of widget IDs. |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
```js
var formId = "12400633174999288";
formHost.notifyVisibleForms(formId, (error, data) => {
if (error) {
console.log('formHost notifyVisibleForms, error:' + error.code);
if (error.code) {
console.log('formHost notifyVisibleForms, error:' + JSON.stringify(error));
}
});
```
## notifyVisibleForms
notifyVisibleForms(formId: string): Promise&lt;void&gt;;
notifyVisibleForms(formIds: Array&lt;string&gt;): Promise&lt;void&gt;;
Instructs the widget framework to make a widget visible. This API uses a promise to return the result. After this API is called, **onVisibilityChange** is invoked to notify the widget provider.
**System capability**:
**System capability**
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formIds | Array&lt;string&gt; | Yes | List of widget IDs.|
**Return value**
......@@ -337,54 +345,56 @@ SystemCapability.Ability.Form
```js
var formId = "12400633174999288";
formHost.notifyVisibleForms(formId).catch((error) => {
console.log('formProvider notifyVisibleForms, error:' + JSON.stringify(error));
formHost.notifyVisibleForms(formId).then(() => {
console.log('formHost notifyVisibleForms success');
}).catch((error) => {
console.log('formHost notifyVisibleForms, error:' + JSON.stringify(error));
});
```
## notifyInvisibleForms
notifyInvisibleForms(formId: string, callback: AsyncCallback&lt;void&gt;): void;
notifyInvisibleForms(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;void&gt;): void;
Instructs the widget framework to make a widget invisible. This API uses an asynchronous callback to return the result. After this API is called, **onVisibilityChange** is invoked to notify the widget provider.
**System capability**:
**System capability**
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formIds | Array&lt;string&gt; | Yes | List of widget IDs. |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
```js
var formId = "12400633174999288";
formHost.notifyInvisibleForms(formId, (error, data) => {
if (error) {
console.log('formHost notifyInvisibleForms, error:' + error.code);
if (error.code) {
console.log('formHost notifyInvisibleForms, error:' + JSON.stringify(error));
}
});
```
## notifyInvisibleForms
notifyInvisibleForms(formId: string): Promise&lt;void&gt;;
notifyInvisibleForms(formIds: Array&lt;string&gt;): Promise&lt;void&gt;;
Instructs the widget framework to make a widget invisible. This API uses a promise to return the result. After this API is called, **onVisibilityChange** is invoked to notify the widget provider.
**System capability**:
**System capability**
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formIds | Array&lt;string&gt; | Yes | List of widget IDs.|
**Return value**
......@@ -396,54 +406,56 @@ SystemCapability.Ability.Form
```js
var formId = "12400633174999288";
formHost.notifyInvisibleForms(formId).catch((error) => {
console.log('formProvider notifyInvisibleForms, error:' + JSON.stringify(error));
formHost.notifyInvisibleForms(formId).then(() => {
console.log('formHost notifyInvisibleForms success');
}).catch((error) => {
console.log('formHost notifyInvisibleForms, error:' + JSON.stringify(error));
});
```
## enableFormsUpdate
enableFormsUpdate(formId: string, callback: AsyncCallback&lt;void&gt;): void;
enableFormsUpdate(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;void&gt;): void;
Instructs the widget framework to make a widget to be updatable. This API uses an asynchronous callback to return the result. After this API is called, the widget is in the enabled state and can receive updates from the widget provider.
Instructs the widget framework to make a widget updatable. This API uses an asynchronous callback to return the result. After this API is called, the widget is in the enabled state and can receive updates from the widget provider.
**System capability**:
**System capability**
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formIds | Array&lt;string&gt; | Yes | List of widget IDs. |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
```js
var formId = "12400633174999288";
formHost.enableFormsUpdate(formId, (error, data) => {
if (error) {
console.log('formHost enableFormsUpdate, error:' + error.code);
if (error.code) {
console.log('formHost enableFormsUpdate, error:' + JSON.stringify(error));
}
});
```
## enableFormsUpdate
enableFormsUpdate(formId: string): Promise&lt;void&gt;;
enableFormsUpdate(formIds: Array&lt;string&gt;): Promise&lt;void&gt;;
Instructs the widget framework to make a widget to be updatable. This API uses a promise to return the result. After this API is called, the widget is in the enabled state and can receive updates from the widget provider.
Instructs the widget framework to make a widget updatable. This API uses a promise to return the result. After this API is called, the widget is in the enabled state and can receive updates from the widget provider.
**System capability**:
**System capability**
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formIds | Array&lt;string&gt; | Yes | List of widget IDs.|
**Return value**
......@@ -455,54 +467,56 @@ SystemCapability.Ability.Form
```js
var formId = "12400633174999288";
formHost.enableFormsUpdate(formId).catch((error) => {
console.log('formProvider enableFormsUpdate, error:' + JSON.stringify(error));
formHost.enableFormsUpdate(formId).then(() => {
console.log('formHost enableFormsUpdate success');
}).catch((error) => {
console.log('formHost enableFormsUpdate, error:' + JSON.stringify(error));
});
```
## disableFormsUpdate
disableFormsUpdate(formId: string, callback: AsyncCallback&lt;void&gt;): void;
disableFormsUpdate(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;void&gt;): void;
Instructs the widget framework to make a widget not to be updatable. This API uses an asynchronous callback to return the result. After this API is called, the widget is in the disabled state and cannot receive updates from the widget provider.
Instructs the widget framework to make a widget not updatable. This API uses an asynchronous callback to return the result. After this API is called, the widget cannot receive updates from the widget provider.
**System capability**:
**System capability**
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formIds | Array&lt;string&gt; | Yes | List of widget IDs. |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
```js
var formId = "12400633174999288";
formHost.disableFormsUpdate(formId, (error, data) => {
if (error) {
console.log('formHost disableFormsUpdate, error:' + error.code);
if (error.code) {
console.log('formHost disableFormsUpdate, error:' + JSON.stringify(error));
}
});
```
## disableFormsUpdate
disableFormsUpdate(formId: string): Promise&lt;void&gt;;
disableFormsUpdate(formIds: Array&lt;string&gt;): Promise&lt;void&gt;;
Instructs the widget framework to make a widget not to be updatable. This API uses a promise to return the result. After this API is called, the widget is in the disabled state and cannot receive updates from the widget provider.
Instructs the widget framework to make a widget not updatable. This API uses a promise to return the result. After this API is called, the widget cannot receive updates from the widget provider.
**System capability**:
**System capability**
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formIds | Array&lt;string&gt; | Yes | List of widget IDs.|
**Return value**
......@@ -514,8 +528,10 @@ SystemCapability.Ability.Form
```js
var formId = "12400633174999288";
formHost.disableFormsUpdate(formId).catch((error) => {
console.log('formProvider disableFormsUpdate, error:' + JSON.stringify(error));
formHost.disableFormsUpdate(formId).then(() => {
console.log('formHost disableFormsUpdate success');
}).catch((error) => {
console.log('formHost disableFormsUpdate, error:' + JSON.stringify(error));
});
```
......@@ -525,23 +541,23 @@ isSystemReady(callback: AsyncCallback&lt;void&gt;): void;
Checks whether the system is ready. This API uses an asynchronous callback to return the result.
**System capability**:
**System capability**
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
```js
var formId = "12400633174999288";
formHost.isSystemReady((error, data) => {
if (error) {
console.log('formHost isSystemReady, error:' + error.code);
if (error.code) {
console.log('formHost isSystemReady, error:' + JSON.stringify(error));
}
});
```
......@@ -552,7 +568,7 @@ isSystemReady(): Promise&lt;void&gt;;
Checks whether the system is ready. This API uses a promise to return the result.
**System capability**:
**System capability**
SystemCapability.Ability.Form
......@@ -566,8 +582,10 @@ SystemCapability.Ability.Form
```js
var formId = "12400633174999288";
formHost.isSystemReady().catch((error) => {
console.log('formProvider isSystemReady, error:' + JSON.stringify(error));
formHost.isSystemReady().then(() => {
console.log('formHost isSystemReady success');
}).catch((error) => {
console.log('formHost isSystemReady, error:' + JSON.stringify(error));
});
```
......@@ -577,7 +595,7 @@ getAllFormsInfo(callback: AsyncCallback&lt;Array&lt;FormInfo&gt;&gt;): void;
Obtains the widget information provided by all applications on the device. This API uses an asynchronous callback to return the result.
**System capability**:
**System capability**
SystemCapability.Ability.Form
......@@ -591,8 +609,10 @@ SystemCapability.Ability.Form
```js
formHost.getAllFormsInfo((error, data) => {
if (error) {
console.log('formHost getAllFormsInfo, error:' + error.code);
if (error.code) {
console.log('formHost getAllFormsInfo, error:' + JSON.stringify(error));
} else {
console.log('formHost getAllFormsInfo, data:' + JSON.stringify(data));
}
});
```
......@@ -603,7 +623,7 @@ getAllFormsInfo(): Promise&lt;Array&lt;FormInfo&gt;&gt;;
Obtains the widget information provided by all applications on the device. This API uses a promise to return the result.
**System capability**:
**System capability**
SystemCapability.Ability.Form
......@@ -616,8 +636,10 @@ SystemCapability.Ability.Form
**Example**
```js
formHost.getAllFormsInfo().catch((error) => {
console.log('formProvider getAllFormsInfo, error:' + JSON.stringify(error));
formHost.getAllFormsInfo().then((data) => {
console.log('formHost getAllFormsInfo data:' + JSON.stringify(data));
}).catch((error) => {
console.log('formHost getAllFormsInfo, error:' + JSON.stringify(error));
});
```
......@@ -627,7 +649,7 @@ getFormsInfo(bundleName: string, callback: AsyncCallback&lt;Array&lt;FormInfo&gt
Obtains the widget information provided by a given application on the device. This API uses an asynchronous callback to return the result.
**System capability**:
**System capability**
SystemCapability.Ability.Form
......@@ -641,9 +663,11 @@ SystemCapability.Ability.Form
**Example**
```js
formHost.getFormsInfo("com.example.ohos.accountjsdemo", (error, data) => {
if (error) {
console.log('formHost getFormsInfo, error:' + error.code);
formHost.getFormsInfo("com.example.ohos.formjsdemo", (error, data) => {
if (error.code) {
console.log('formHost getFormsInfo, error:' + JSON.stringify(error));
} else {
console.log('formHost getFormsInfo, data:' + JSON.stringify(data));
}
});
```
......@@ -654,7 +678,7 @@ getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback&lt;
Obtains the widget information provided by a given application on the device. This API uses an asynchronous callback to return the result.
**System capability**:
**System capability**
SystemCapability.Ability.Form
......@@ -669,9 +693,11 @@ SystemCapability.Ability.Form
**Example**
```js
formHost.getFormsInfo("com.example.ohos.accountjsdemo", (error, data) => {
if (error) {
console.log('formHost getFormsInfo, error:' + error.code);
formHost.getFormsInfo("com.example.ohos.formjsdemo", "entry", (error, data) => {
if (error.code) {
console.log('formHost getFormsInfo, error:' + JSON.stringify(error));
} else {
console.log('formHost getFormsInfo, data:' + JSON.stringify(data));
}
});
```
......@@ -682,7 +708,7 @@ getFormsInfo(bundleName: string, moduleName?: string): Promise&lt;Array&lt;FormI
Obtains the widget information provided by a given application on the device. This API uses a promise to return the result.
**System capability**:
**System capability**
SystemCapability.Ability.Form
......@@ -702,8 +728,10 @@ SystemCapability.Ability.Form
**Example**
```js
formHost.getAllFormsInfo().catch((error) => {
console.log('formProvider getAllFormsInfo, error:' + JSON.stringify(error));
formHost.getFormsInfo("com.example.ohos.formjsdemo", "entry").then((data) => {
console.log('formHost getFormsInfo, data:' + JSON.stringify(data));
}).catch((error) => {
console.log('formHost getFormsInfo, error:' + JSON.stringify(error));
});
```
......@@ -713,43 +741,45 @@ deleteInvalidForms(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;numb
Deletes invalid widgets from the list. This API uses an asynchronous callback to return the result.
**System capability**:
**System capability**
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formIds | Array&lt;string&gt; | Yes | List of widget IDs.|
| callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the number of widgets deleted.|
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formIds | Array&lt;string&gt; | Yes | List of valid widget IDs.|
| callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the number of widgets deleted.|
**Example**
```js
var formIds = new Array("12400633174999288", "12400633174999289");
formHost.deleteInvalidForms(formIds, (error, data) => {
if (error) {
console.log('formHost deleteInvalidForms, error:' + error.code);
if (error.code) {
console.log('formHost deleteInvalidForms, error:' + JSON.stringify(error));
} else {
console.log('formHost deleteInvalidForms, data:' + JSON.stringify(data));
}
});
```
## deleteInvalidForms
function deleteInvalidForms(formIds: Array&ltstring&gt): Promise&lt;number&gt;;
function deleteInvalidForms(formIds: Array&lt;string&gt;): Promise&lt;number&gt;;
Deletes invalid widgets from the list. This API uses a promise to return the result.
**System capability**:
**System capability**
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formIds | Array&lt;string&gt; | Yes | List of widget IDs.|
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formIds | Array&lt;string&gt; | Yes | List of valid widget IDs.|
**Return value**
......@@ -761,8 +791,10 @@ SystemCapability.Ability.Form
```js
var formIds = new Array("12400633174999288", "12400633174999289");
formHost.deleteInvalidForms(formIds).catch((error) => {
console.log('formProvider deleteInvalidForms, error:' + JSON.stringify(error));
formHost.deleteInvalidForms(formIds).then((data) => {
console.log('formHost deleteInvalidForms, data:' + JSON.stringify(data));
}).catch((error) => {
console.log('formHost deleteInvalidForms, error:' + JSON.stringify(error));
});
```
......@@ -772,7 +804,7 @@ acquireFormState(want: Want, callback: AsyncCallback&lt;FormStateInfo&gt;): void
Obtains the widget state. This API uses an asynchronous callback to return the result.
**System capability**:
**System capability**
SystemCapability.Ability.Form
......@@ -780,7 +812,7 @@ SystemCapability.Ability.Form
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| want | [Want](js-apis-featureAbility.md#want) | Yes | **Want** information carried to query the widget state.|
| want | [Want](js-apis-application-Want.md) | Yes | **Want** information carried to query the widget state.|
| callback | AsyncCallback&lt;[FormStateInfo](js-apis-formInfo.md#formstateinfo)&gt; | Yes| Callback used to return the widget state.|
**Example**
......@@ -792,8 +824,10 @@ SystemCapability.Ability.Form
"abilityName": "com.extreme.test.MainAbility"
};
formHost.acquireFormState(want, (error, data) => {
if (error) {
console.log('formHost acquireFormState, error:' + error.code);
if (error.code) {
console.log('formHost acquireFormState, error:' + JSON.stringify(error));
} else {
console.log('formHost acquireFormState, data:' + JSON.stringify(data));
}
});
```
......@@ -806,9 +840,9 @@ Obtains the widget state. This API uses a promise to return the result.
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formIds | Array&lt;string&gt; | Yes | List of widget IDs.|
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| want | [Want](js-apis-application-Want.md) | Yes | **Want** information carried to query the widget state.|
**Return value**
......@@ -816,7 +850,7 @@ Obtains the widget state. This API uses a promise to return the result.
| :------------ | :---------------------------------- |
| Promise&lt;[FormStateInfo](js-apis-formInfo.md#formstateinfo)&gt; | Promise used to return the widget state.|
**System capability**:
**System capability**
SystemCapability.Ability.Form
......@@ -828,8 +862,10 @@ SystemCapability.Ability.Form
"bundleName": "com.extreme.test",
"abilityName": "com.extreme.test.MainAbility"
};
formHost.acquireFormState(want).catch((error) => {
console.log('formProvider acquireFormState, error:' + JSON.stringify(error));
formHost.acquireFormState(want).then((data) => {
console.log('formHost acquireFormState, data:' + JSON.stringify(data));
}).catch((error) => {
console.log('formHost acquireFormState, error:' + JSON.stringify(error));
});
```
......@@ -839,52 +875,50 @@ on(type: "formUninstall", callback: Callback&lt;string&gt;): void;
Subscribes to widget uninstall events.
**System capability**:
**System capability**
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| type | string | Yes | Type of event to subscribe to. The value **formUninstall** indicates a widget uninstallation event.|
| callback | Callback&lt;string&gt; | Yes| Callback used to return the result.|
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| type | string | Yes | Type of event to subscribe to. The value **formUninstall** indicates a widget uninstallation event.|
| callback | Callback&lt;string&gt; | Yes| Callback used for event subscription.|
**Example**
```js
formHost.on("formUninstall", (error, data) => {
if (error) {
console.log('formHost on formUninstall, error:' + error.code);
}
});
let callback = function(formId) {
console.log('formHost on formUninstall, formId:' + formId);
}
formHost.on("formUninstall", callback);
```
## off("formUninstall")
off(type: "formUninstall", callback: Callback&lt;string&gt;): void;
off(type: "formUninstall", callback?: Callback&lt;string&gt;): void;
Unsubscribes from widget uninstall events.
**System capability**:
**System capability**
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| type | string | Yes | Type of event to unsubscribe from. The value **formUninstall** indicates a widget uninstallation event.|
| callback | Callback&lt;string&gt; | Yes| Callback used to return the result.|
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| type | string | Yes | Type of event to subscribe to. The value **formUninstall** indicates a widget uninstallation event.|
| callback | Callback&lt;string&gt; | No| Callback used for event unsubscription. If it is left unspecified, it indicates the callback for all the events that have been subscribed.|
**Example**
```js
formHost.off("formUninstall", (error, data) => {
if (error) {
console.log('formHost off formUninstall, error:' + error.code);
}
});
let callback = function(formId) {
console.log('formHost on formUninstall, formId:' + formId);
}
formHost.off("formUninstall", callback);
```
## notifyFormsVisible
......@@ -893,25 +927,25 @@ notifyFormsVisible(formIds: Array&lt;string&gt;, isVisible: boolean, callback: A
Instructs the widgets to make themselves visible. This API uses an asynchronous callback to return the result.
**System capability**:
**System capability**
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formIds | Array&lt;string&gt; | Yes | List of widget IDs.|
| isVisible | boolean | Yes | Whether to be visible.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formIds | Array&lt;string&gt; | Yes | List of widget IDs.|
| isVisible | boolean | Yes | Whether to be visible.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
```js
var formIds = new Array("12400633174999288", "12400633174999289");
formHost.notifyFormsVisible(formIds, true, (error, data) => {
if (error) {
console.log('formHost notifyFormsVisible, error:' + error.code);
if (error.code) {
console.log('formHost notifyFormsVisible, error:' + JSON.stringify(error));
}
});
```
......@@ -922,7 +956,7 @@ notifyFormsVisible(formIds: Array&lt;string&gt;, isVisible: boolean): Promise&lt
Instructs the widgets to make themselves visible. This API uses a promise to return the result.
**System capability**:
**System capability**
SystemCapability.Ability.Form
......@@ -943,8 +977,10 @@ SystemCapability.Ability.Form
```js
var formIds = new Array("12400633174999288", "12400633174999289");
formHost.notifyFormsVisible(formIds, true).catch((error) => {
console.log('formProvider notifyFormsVisible, error:' + JSON.stringify(error));
formHost.notifyFormsVisible(formIds, true).then(() => {
console.log('formHost notifyFormsVisible success');
}).catch((error) => {
console.log('formHost notifyFormsVisible, error:' + JSON.stringify(error));
});
```
......@@ -952,27 +988,27 @@ SystemCapability.Ability.Form
notifyFormsEnableUpdate(formIds: Array&lt;string&gt;, isEnableUpdate: boolean, callback: AsyncCallback&lt;void&gt;): void;
Instructs the widgets to enable or disable update. This API uses an asynchronous callback to return the result.
Instructs the widgets to enable or disable updates. This API uses an asynchronous callback to return the result.
**System capability**:
**System capability**
SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formIds | Array&lt;string&gt; | Yes | List of widget IDs.|
| isEnableUpdate | boolean | Yes | Whether to enable update.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| formIds | Array&lt;string&gt; | Yes | List of widget IDs.|
| isEnableUpdate | boolean | Yes | Whether to enable update.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
```js
var formIds = new Array("12400633174999288", "12400633174999289");
formHost.notifyFormsEnableUpdate(formIds, true, (error, data) => {
if (error) {
console.log('formHost notifyFormsEnableUpdate, error:' + error.code);
if (error.code) {
console.log('formHost notifyFormsEnableUpdate, error:' + JSON.stringify(error));
}
});
```
......@@ -981,9 +1017,9 @@ SystemCapability.Ability.Form
notifyFormsEnableUpdate(formIds: Array&lt;string&gt;, isEnableUpdate: boolean): Promise&lt;void&gt;;
Instructs the widgets to enable or disable update. This API uses a promise to return the result.
Instructs the widgets to enable or disable updates. This API uses a promise to return the result.
**System capability**:
**System capability**
SystemCapability.Ability.Form
......@@ -1004,7 +1040,9 @@ SystemCapability.Ability.Form
```js
var formIds = new Array("12400633174999288", "12400633174999289");
formHost.notifyFormsEnableUpdate(formIds, true).catch((error) => {
console.log('formProvider notifyFormsEnableUpdate, error:' + JSON.stringify(error));
formHost.notifyFormsEnableUpdate(formIds, true).then(() => {
console.log('formHost notifyFormsEnableUpdate success');
}).catch((error) => {
console.log('formHost notifyFormsEnableUpdate, error:' + JSON.stringify(error));
});
```
# missionManager
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> 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.
Provides mission management. You can use the APIs to lock, unlock, and clear missions, and switch a mission to the foreground.
missionManager provides APIs to lock, unlock, and clear missions, and switch a mission to the foreground.
## Modules to Import
......@@ -34,7 +34,7 @@ Registers a listener to observe the mission status.
| Type| Description|
| -------- | -------- |
| number | Returns the index of the listener, which is created by the system and allocated when the mission status listener is registered. Each listener has a unique index.|
| number | Returns the unique index of the mission status listener, which is created by the system and allocated when the listener is registered.|
**Example**
......@@ -55,7 +55,7 @@ Registers a listener to observe the mission status.
unregisterMissionListener(listenerId: number, callback: AsyncCallback&lt;void&gt;): void;
Unregisters a mission status listener. This API uses an asynchronous callback to return the result.
Deregisters a mission status listener. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
......@@ -63,7 +63,7 @@ Unregisters a mission status listener. This API uses an asynchronous callback to
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| listenerId | number | Yes| Index of the mission status listener to unregister. Each listener has a unique index, which is returned by **registerMissionListener**.|
| listenerId | number | Yes| Unique index of the mission status listener to unregister. It is returned by **registerMissionListener**.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
......@@ -88,7 +88,7 @@ Unregisters a mission status listener. This API uses an asynchronous callback to
unregisterMissionListener(listenerId: number): Promise&lt;void&gt;;
Unregisters a mission status listener. This API uses a promise to return the result.
Deregisters a mission status listener. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
......@@ -96,7 +96,7 @@ Unregisters a mission status listener. This API uses a promise to return the res
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| listenerId | number | Yes| Index of the mission status listener to unregister. Each listener has a unique index, which is returned by **registerMissionListener**.|
| listenerId | number | Yes| Unique index of the mission status listener to unregister. It is returned by **registerMissionListener**.|
**Return value**
......@@ -126,7 +126,7 @@ Unregisters a mission status listener. This API uses a promise to return the res
getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback&lt;MissionInfo&gt;): void;
Obtains the information of a given mission. This API uses an asynchronous callback to return the result.
Obtains the information about a given mission. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
......@@ -159,7 +159,7 @@ Obtains the information of a given mission. This API uses an asynchronous callba
getMissionInfo(deviceId: string, missionId: number): Promise&lt;MissionInfo&gt;;
Obtains the information of a given mission. This API uses a promise to return the result.
Obtains the information about a given mission. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
......@@ -191,7 +191,7 @@ Obtains the information of a given mission. This API uses a promise to return th
getMissionInfos(deviceId: string, numMax: number, callback: AsyncCallback&lt;Array&lt;MissionInfo&gt;&gt;): void;
Obtains information of all missions. This API uses an asynchronous callback to return the result.
Obtains information about all missions. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
......@@ -220,7 +220,7 @@ Obtains information of all missions. This API uses an asynchronous callback to r
getMissionInfos(deviceId: string, numMax: number): Promise&lt;Array&lt;MissionInfo&gt;&gt;;
Obtains information of all missions. This API uses a promise to return the result.
Obtains information about all missions. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
......@@ -617,7 +617,7 @@ Switches a given mission to the foreground. This API uses an asynchronous callba
moveMissionToFront(missionId: number, options: StartOptions, callback: AsyncCallback&lt;void&gt;): void;
Switches a given mission to the foreground, with the startup parameters for the switch specified, such as the window mode and device ID. This API uses an asynchronous callback to return the result.
Switches a given mission to the foreground, with the startup parameters for the switching specified. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
......@@ -651,7 +651,7 @@ Switches a given mission to the foreground, with the startup parameters for the
moveMissionToFront(missionId: number, options?: StartOptions): Promise&lt;void&gt;;
Switches a given mission to the foreground, with the startup parameters for the switch specified, such as the window mode and device ID. This API uses a promise to return the result.
Switches a given mission to the foreground, with the startup parameters for the switching specified. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
......@@ -697,7 +697,7 @@ Describes the mission information.
| runningState | number | Yes| Yes| Running state of the mission.|
| lockedState | boolean | Yes| Yes| Locked state of the mission.|
| timestamp | string | Yes| Yes| Latest time when the mission was created or updated.|
| want | [Want](js-apis-featureAbility.md#want) | Yes| Yes| **Want** information of the mission.|
| want | [Want](js-apis-application-Want.md) | Yes| Yes| **Want** information of the mission.|
| label | string | Yes| Yes| Label of the mission.|
| iconPath | string | Yes| Yes| Path of the mission icon.|
| continuable | boolean | Yes| Yes| Whether the mission is continuable.|
# ParticleAbility Module
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Constraints
......@@ -260,16 +260,16 @@ Requests a continuous task from the system. This API uses a promise to return th
**Parameters**
| Name| Type| Mandatory| Description|
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| id | number | Yes| Notification ID of a continuous task.|
| request | NotificationRequest | Yes| Notification parameter, which is used to display information in the notification bar.|
| id | number | Yes | Notification ID of a continuous task. |
| request | NotificationRequest | Yes | Notification parameter, which is used to display information in the notification bar. |
**Return value**
| Type | Description |
| Type | Description |
| -------------- | ------------------------- |
| Promise\<void> | Promise used to return the result.|
| Promise\<void> | Promise used to return the result. |
**Example**
......@@ -323,9 +323,9 @@ Requests to cancel a continuous task from the system. This API uses an asynchron
**Parameters**
| Name| Type| Mandatory| Description|
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
......@@ -354,9 +354,9 @@ Requests a continuous task from the system. This API uses a promise to return th
**Return value**
| Type | Description |
| Type | Description |
| -------------- | ------------------------- |
| Promise\<void> | Promise used to return the result.|
| Promise\<void> | Promise used to return the result. |
**Example**
......@@ -382,21 +382,21 @@ Connects this ability to a specific Service ability. This API uses a callback to
**Parameters**
| Name | Type | Mandatory| Description |
| Name | Type | Mandatory | Description |
| ------- | -------------- | ---- | ---------------------------- |
| request | [Want](js-apis-featureAbility.md#want) | Yes | Service ability to connect.|
| options | ConnectOptions | Yes | Callback used to return the result. |
| request | [Want](js-apis-application-Want.md) | Yes | Service ability to connect. |
| options | ConnectOptions | Yes | Callback used to return the result. |
ConnectOptions
**ConnectOptions**
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Readable/Writable| Type | Mandatory | Description |
| Name | Readable/Writable | Type | Mandatory | Description |
| ------------ | ---- | -------- | ---- | ------------------------- |
| onConnect | Read only | function | Yes | Callback invoked when the connection is successful. |
| onDisconnect | Read only | function | Yes | Callback invoked when the connection fails. |
| onFailed | Read only | function | Yes | Callback invoked when **connectAbility** fails to be called.|
| onConnect | Read only | function | Yes | Callback invoked when the connection is successful. |
| onDisconnect | Read only | function | Yes | Callback invoked when the connection fails. |
| onFailed | Read only | function | Yes | Callback invoked when **connectAbility** fails to be called. |
**Example**
......@@ -440,9 +440,9 @@ Disconnects this ability from the Service ability. This API uses a callback to r
**Parameters**
| Name| Type| Mandatory| Description|
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
......@@ -486,9 +486,9 @@ Disconnects this ability from the Service ability. This API uses a promise to re
**Return value**
| Type | Description |
| Type | Description |
| -------------- | ------------------------- |
| Promise\<void> | Promise used to return the result.|
| Promise\<void> | Promise used to return the result. |
**Example**
......
......@@ -279,7 +279,7 @@ A data record is an abstract definition of the content on the pasteboard. The pa
| Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- |
| htmlText<sup>7+</sup> | string | Yes | No | HTML text. |
| want<sup>7+</sup> | [Want](js-apis-featureAbility.md#want) | Yes | No | Want text. |
| want<sup>7+</sup> | [Want](js-apis-application-Want.md) | Yes | No | Want text. |
| mimeType<sup>7+</sup> | string | Yes | No | Data type. |
| plainText<sup>7+</sup> | string | Yes | No | Plain text. |
| uri<sup>7+</sup> | string | Yes | No | URI text. |
......@@ -506,7 +506,7 @@ The pasteboard supports a maximum number of 128 data records.
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-featureAbility.md#want) | Yes | Want object. |
| want | [Want](js-apis-application-Want.md) | Yes | Want object. |
**Example**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
新手
引导
客服 返回
顶部