未验证 提交 8f6952fa 编写于 作者: O openharmony_ci 提交者: Gitee

!18172 翻译完成:17384+17742+17385 errorcode issue

Merge pull request !18172 from wusongqing/TR17384
......@@ -3,7 +3,7 @@
The **missionManager** module provides APIs to lock, unlock, and clear missions, and switch a mission to the foreground.
> **NOTE**
>
>
> 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.
## Modules to Import
......@@ -32,7 +32,7 @@ Registers a listener to observe the mission status.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| listener | [MissionListener](js-apis-inner-application-missionListener.md) | Yes| Mission status listener to register.|
| listener | [MissionListener](js-apis-inner-application-missionListener.md) | Yes| Listener to register.|
**Return value**
......@@ -79,7 +79,7 @@ export default class EntryAbility extends UIAbility {
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
// The main window is created. Set a main page for this ability.
console.log('[Demo] EntryAbility onWindowStageCreate');
try {
listenerId = missionManager.on('mission', listener);
......@@ -107,7 +107,7 @@ export default class EntryAbility extends UIAbility {
off(type: 'mission', listenerId: number, callback: AsyncCallback<void>): void;
Deregisters a mission status listener.
Deregisters a mission status listener. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.MANAGE_MISSIONS
......@@ -122,6 +122,14 @@ Deregisters a mission status listener.
| listenerId | number | Yes| Index of the mission status listener to deregister. It is returned by **registerMissionListener()**.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 16300002 | Input error. The specified mission listener does not exist. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
......@@ -161,7 +169,7 @@ export default class EntryAbility extends UIAbility {
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
// The main window is created. Set a main page for this ability.
console.log('[Demo] EntryAbility onWindowStageCreate');
try {
listenerId = missionManager.on('mission', listener);
......@@ -205,9 +213,17 @@ Deregisters a mission status listener. This API uses a promise to return the res
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
| Promise<void> | Promise used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 16300002 | Input error. The specified mission listener does not exist. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
......@@ -248,7 +264,7 @@ export default class EntryAbility extends UIAbility {
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
// The main window is created. Set a main page for this ability.
console.log('[Demo] EntryAbility onWindowStageCreate');
try {
listenerId = missionManager.on('mission', listener);
......@@ -631,6 +647,14 @@ Locks a given mission. This API uses an asynchronous callback to return the resu
| missionId | number | Yes| Mission ID.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 16300001 | Mission not found. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
......@@ -673,9 +697,17 @@ Locks a given mission. This API uses a promise to return the result.
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
| Promise<void> | Promise used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 16300001 | Mission not found. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
......@@ -719,6 +751,14 @@ Unlocks a given mission. This API uses an asynchronous callback to return the re
| missionId | number | Yes| Mission ID.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 16300001 | Mission not found. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
......@@ -761,9 +801,17 @@ Unlocks a given mission. This API uses a promise to return the result.
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
| Promise<void> | Promise used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 16300001 | Mission not found. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
......@@ -852,9 +900,9 @@ Clears a given mission, regardless of whether it is locked. This API uses a prom
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
| Promise<void> | Promise used to return the result.|
**Example**
......@@ -916,9 +964,9 @@ Clears all unlocked missions. This API uses a promise to return the result.
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
| Promise<void> | Promise used to return the result.|
**Example**
......@@ -949,6 +997,14 @@ Switches a given mission to the foreground. This API uses an asynchronous callba
| missionId | number | Yes| Mission ID.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
......@@ -991,6 +1047,14 @@ Switches a given mission to the foreground, with the startup parameters for the
| options | [StartOptions](js-apis-app-ability-startOptions.md) | Yes| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
......@@ -1034,9 +1098,17 @@ Switches a given mission to the foreground, with the startup parameters for the
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
| Promise<void> | Promise used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
......
......@@ -62,6 +62,25 @@ Applies a quick fix patch. This API uses an asynchronous callback to return the
| hapModuleQuickFixFiles | Array\<string> | Yes| Quick fix patch files, each of which must contain a valid file path.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 18500002 | Copy file failed, maybe not exist or inaccessible. |
| 18500008 | Internal error. |
If an error occurs during patch installation, the error code and message are returned through the common event [COMMON_EVENT_QUICK_FIX_APPLY_RESULT](commonEvent-definitions.md#common_event_quick_fix_apply_result9). The table below lists the possible error codes and messages.
| ID| Error Message|
| ------- | -------- |
| 18500003 | Deploy hqf failed. |
| 18500004 | Switch hqf failed. |
| 18500005 | Delete hqf failed. |
| 18500006 | Load patch failed. |
| 18500007 | Unload patch failed. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
> **NOTE**
>
> The file path passed in the API must be an application sandbox path. For details about how to obtain the sandbox path, see [Obtaining the Sandbox Path](js-apis-bundle-BundleInstaller.md#obtaining-the-sandbox-path). The path mapped to the device is **/proc/<*applicationProcessId*>/root/*sandboxPath***.
......@@ -109,6 +128,25 @@ Applies a quick fix patch. This API uses a promise to return the result.
| -------- | -------- |
| Promise\<void> | Promise used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 18500002 | Copy file failed, maybe not exist or inaccessible. |
| 18500008 | Internal error. |
If an error occurs during patch installation, the error code and message are returned through the common event [COMMON_EVENT_QUICK_FIX_APPLY_RESULT](commonEvent-definitions.md#common_event_quick_fix_apply_result9). The table below lists the possible error codes and messages.
| ID| Error Message|
| ------- | -------- |
| 18500003 | Deploy hqf failed. |
| 18500004 | Switch hqf failed. |
| 18500005 | Delete hqf failed. |
| 18500006 | Load patch failed. |
| 18500007 | Unload patch failed. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
......@@ -145,6 +183,15 @@ Obtains the quick fix information of the application. This API uses an asynchron
| bundleName | string | Yes|Bundle name. |
| callback | AsyncCallback\<[ApplicationQuickFixInfo](#applicationquickfixinfo)> | Yes| Callback used to return the quick fix information.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 18500001 | The bundle is not exist. |
| 18500008 | Internal error. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
......@@ -188,6 +235,15 @@ Obtains the quick fix information of the application. This API uses a promise to
| -------- | -------- |
| Promise\<[ApplicationQuickFixInfo](#applicationquickfixinfo)> | Promise used to return the quick fix information.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 18500001 | The bundle is not exist. |
| 18500008 | Internal error. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```ts
......
# @ohos.app.ability.wantAgent (WantAgent)
The **WantAgent** module provides APIs for creating and comparing **WantAgent** objects, and obtaining the user ID and bundle name of a **WantAgent** object. You are advised to use this module, since it will replace the [@ohos.wantAgent](js-apis-wantAgent.md) module in the near future.
The **WantAgent** module provides APIs for triggering, canceling, and comparing **WantAgent** objects. You can use the APIs to create a **WantAgent** object, and obtain the user ID, bundle name, and want information of the object.
> **NOTE**
>
......@@ -24,9 +24,18 @@ Obtains a **WantAgent** object. This API uses an asynchronous callback to return
| Name | Type | Mandatory| Description |
| -------- | -------------------------- | ---- | ----------------------- |
| info | [WantAgentInfo](js-apis-inner-wantAgent-wantAgentInfo.md) | Yes | Information about the **WantAgent** object to obtain. |
| info | WantAgentInfo | Yes | Information about the **WantAgent** object to obtain. |
| callback | AsyncCallback\<WantAgent\> | Yes | Callback used to return the **WantAgent** object.|
**Error codes**
| ID | Error Message |
|-----------|--------------------|
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
| 16000151 | Invalid wantagent object.|
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```js
......@@ -93,6 +102,15 @@ Obtains a **WantAgent** object. This API uses a promise to return the result. If
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<WantAgent\> | Promise used to return the **WantAgent** object.|
**Error codes**
| ID | Error Message |
|-----------|--------------------|
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
| 16000151 | Invalid wantagent object.|
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```js
......@@ -153,16 +171,25 @@ Obtains the bundle name of a **WantAgent** object. This API uses an asynchronous
| agent | WantAgent | Yes | Target **WantAgent** object. |
| callback | AsyncCallback\<string\> | Yes | Callback used to return the bundle name.|
**Error codes**
| ID | Error Message |
|-----------|--------------------|
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
| 16000151 | Invalid wantagent object.|
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```js
import WantAgent from '@ohos.app.ability.wantAgent';
// wantAgent object
// WantAgent object
let wantAgent;
//getWantAgent callback
// getWantAgent callback
function getWantAgentCallback(err, data) {
console.info('==========================>getWantAgentCallback=======================>');
if (err.code == 0) {
......@@ -234,16 +261,25 @@ Obtains the bundle name of a **WantAgent** object. This API uses a promise to re
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<string\> | Promise used to return the bundle name.|
**Error codes**
| ID | Error Message |
|-----------|--------------------|
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
| 16000151 | Invalid wantagent object.|
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```js
import WantAgent from '@ohos.app.ability.wantAgent';
// wantAgent object
// WantAgent object
let wantAgent;
//WantAgentInfo object
// WantAgentInfo object
let wantAgentInfo = {
wants: [
{
......@@ -302,13 +338,22 @@ Obtains the user ID of a **WantAgent** object. This API uses an asynchronous cal
| agent | WantAgent | Yes | Target **WantAgent** object. |
| callback | AsyncCallback\<number\> | Yes | Callback used to return the user ID.|
**Error codes**
| ID | Error Message |
|-----------|--------------------|
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
| 16000151 | Invalid wantagent object.|
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```js
import WantAgent from '@ohos.app.ability.wantAgent';
// wantAgent object
// WantAgent object
let wantAgent;
// getWantAgent callback
......@@ -383,13 +428,22 @@ Obtains the user ID of a **WantAgent** object. This API uses a promise to return
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<number\> | Promise used to return the user ID.|
**Error codes**
| ID | Error Message |
|-----------|--------------------|
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
| 16000151 | Invalid wantagent object.|
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```js
import WantAgent from '@ohos.app.ability.wantAgent';
// wantAgent object
// WantAgent object
let wantAgent;
// WantAgentInfo object
......@@ -453,13 +507,23 @@ Obtains the want in a **WantAgent** object. This API uses an asynchronous callba
| agent | WantAgent | Yes | Target **WantAgent** object. |
| callback | AsyncCallback\<[Want](js-apis-app-ability-want.md)\> | Yes | Callback used to return the want.|
**Error codes**
| ID | Error Message |
|-----------|--------------------|
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
| 16000015 | Service timeout.|
| 16000151 | Invalid wantagent object.|
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```js
import WantAgent from '@ohos.app.ability.wantAgent';
// wantAgent object
// WantAgent object
let wantAgent;
// getWantAgent callback
......@@ -536,13 +600,23 @@ Obtains the want in a **WantAgent** object. This API uses a promise to return th
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<Want\> | Promise used to return the want.|
**Error codes**
| ID | Error Message |
|-----------|--------------------|
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
| 16000015 | Service timeout.|
| 16000151 | Invalid wantagent object.|
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```js
import WantAgent from '@ohos.app.ability.wantAgent';
// wantAgent object
// WantAgent object
let wantAgent;
// WantAgentInfo object
......@@ -604,13 +678,22 @@ Cancels a **WantAgent** object. This API uses an asynchronous callback to return
| agent | WantAgent | Yes | Target **WantAgent** object. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
**Error codes**
| ID | Error Message |
|-----------|--------------------|
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
| 16000151 | Invalid wantagent object.|
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```js
import WantAgent from '@ohos.app.ability.wantAgent';
// wantAgent object
// WantAgent object
let wantAgent;
// getWantAgent callback
......@@ -685,13 +768,22 @@ Cancels a **WantAgent** object. This API uses a promise to return the result.
| --------------- | ------------------------------- |
| Promise\<void\> | Promise used to return the result.|
**Error codes**
| ID | Error Message |
|-----------|--------------------|
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
| 16000151 | Invalid wantagent object.|
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```js
import WantAgent from '@ohos.app.ability.wantAgent';
// wantAgent object
// WantAgent object
let wantAgent;
// WantAgentInfo object
......@@ -751,15 +843,16 @@ Triggers a **WantAgent** object. This API uses an asynchronous callback to retur
| Name | Type | Mandatory| Description |
| ----------- | ----------------------------- | ---- | ------------------------------- |
| agent | WantAgent | Yes | Target **WantAgent** object. |
| triggerInfo | TriggerInfo | Yes | **TriggerInfo** object. |
| triggerInfo | TriggerInfo | Yes | **TriggerInfo** object. |
| callback | AsyncCallback\<[CompleteData](#completedata)\> | No | Callback used to return the result.|
**Example**
```js
import WantAgent from '@ohos.app.ability.wantAgent';
// wantAgent object
// WantAgent object
let wantAgent;
// getWantAgent callback
......@@ -823,7 +916,7 @@ try {
equal(agent: WantAgent, otherAgent: WantAgent, callback: AsyncCallback\<boolean\>): void
Checks whether two **WantAgent** objects are equal to determine whether the same operation is from the same application. This API uses an asynchronous callback to return the result.
Checks whether two **WantAgent** objects are equal. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -841,7 +934,7 @@ Checks whether two **WantAgent** objects are equal to determine whether the same
import WantAgent from '@ohos.app.ability.wantAgent';
// wantAgent object
// WantAgent object
let wantAgent1;
let wantAgent2;
......@@ -902,7 +995,7 @@ try {
equal(agent: WantAgent, otherAgent: WantAgent): Promise\<boolean\>
Checks whether two **WantAgent** objects are equal to determine whether the same operation is from the same application. This API uses a promise to return the result.
Checks whether two **WantAgent** objects are equal. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -925,7 +1018,7 @@ Checks whether two **WantAgent** objects are equal to determine whether the same
import WantAgent from '@ohos.app.ability.wantAgent';
// wantAgent object
// WantAgent object
let wantAgent1;
let wantAgent2;
......@@ -987,12 +1080,22 @@ Obtains the operation type of a **WantAgent** object. This API uses an asynchron
| agent | WantAgent | Yes | Target **WantAgent** object. |
| callback | AsyncCallback\<number> | Yes | Callback used to return the operation type.|
**Error codes**
| ID | Error Message |
|-----------|--------------------|
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
| 16000015 | Service timeout.|
| 16000151 | Invalid wantagent object.|
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```js
import WantAgent from '@ohos.app.ability.wantAgent';
// wantAgent object
// WantAgent object
let wantAgent;
// WantAgentInfo object
......@@ -1057,12 +1160,22 @@ Obtains the operation type of a **WantAgent** object. This API uses a promise to
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<number> | Promise used to return the operation type.|
**Error codes**
| ID | Error Message |
|-----------|--------------------|
| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
| 16000015 | Service timeout.|
| 16000151 | Invalid wantagent object.|
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example**
```js
import WantAgent from '@ohos.app.ability.wantAgent';
// wantAgent object
// WantAgent object
let wantAgent;
// WantAgentInfo object
......@@ -1153,4 +1266,3 @@ try {
| finalCode | number | Yes | Request code that triggers the **WantAgent** object.|
| finalData | string | Yes | Final data collected by the common event. |
| extraInfo | {[key: string]: any} | No | Extra information. |
# @ohos.app.form.formProvider (FormProvider)
# @ohos.app.form.formProvider (formProvider)
The **FormProvider** module provides APIs related to the widget provider. You can use the APIs to update a widget, set the next refresh time for a widget, obtain widget information, and request a widget release.
......@@ -32,19 +32,26 @@ Sets the next refresh time for a widget. This API uses an asynchronous callback
| Error Code ID| Error Message|
| -------- | -------- |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. |
| 16501002 | The number of forms exceeds upper bound. |
| 16501003 | The form can not be operated by the current application. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
```ts
var formId = '12400633174999288';
try {
formProvider.setFormNextRefreshTime(formId, 5, (error, data) => {
formProvider.setFormNextRefreshTime(formId, 5, (error) => {
if (error) {
console.log('formProvider setFormNextRefreshTime, error:' + JSON.stringify(error));
} else {
console.log(`formProvider setFormNextRefreshTime success`);
return;
}
console.log(`formProvider setFormNextRefreshTime success`);
});
} catch (error) {
console.log('error' + JSON.stringify(error))
......@@ -77,7 +84,14 @@ Sets the next refresh time for a widget. This API uses a promise to return the r
| Error Code ID| Error Message|
| -------- | -------- |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. |
| 16501002 | The number of forms exceeds upper bound. |
| 16501003 | The form can not be operated by the current application. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
......@@ -115,7 +129,13 @@ Updates a widget. This API uses an asynchronous callback to return the result.
| Error Code ID| Error Message|
| -------- | -------- |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
......@@ -124,12 +144,12 @@ import formBindingData from '@ohos.application.formBindingData';
var formId = '12400633174999288';
try {
let obj = formBindingData.createFormBindingData({temperature:'22c', time:'22:00'});
formProvider.updateForm(formId, obj, (error, data) => {
formProvider.updateForm(formId, obj, (error) => {
if (error) {
console.log('formProvider updateForm, error:' + JSON.stringify(error));
} else {
console.log(`formProvider updateForm success`);
return;
}
console.log(`formProvider updateForm success`);
});
} catch (error) {
console.log(`catch err->${JSON.stringify(error)}`);
......@@ -162,7 +182,13 @@ Updates a widget. This API uses a promise to return the result.
| Error Code ID| Error Message|
| -------- | -------- |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500060 | A service connection error happened, please try again later. |
| 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. |
| 16501001 | The ID of the form to be operated does not exist. |
| 16501003 | The form can not be operated by the current application. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
......@@ -196,11 +222,13 @@ Obtains the application's widget information on the device. This API uses an asy
| callback | AsyncCallback&lt;Array&lt;[FormInfo](js-apis-app-form-formInfo.md)&gt;&gt; | Yes| Callback used to return the information obtained.|
**Error codes**
| Error Code ID| Error Message|
| -------- | -------- |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
......@@ -210,9 +238,9 @@ try {
formProvider.getFormsInfo((error, data) => {
if (error) {
console.log('formProvider getFormsInfo, error:' + JSON.stringify(error));
} else {
console.log('formProvider getFormsInfo, data:' + JSON.stringify(data));
return;
}
console.log('formProvider getFormsInfo, data:' + JSON.stringify(data));
});
} catch (error) {
console.log(`catch err->${JSON.stringify(error)}`);
......@@ -238,7 +266,10 @@ Obtains the application's widget information that meets a filter criterion on th
| Error Code ID| Error Message|
| -------- | -------- |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
......@@ -253,9 +284,9 @@ try {
formProvider.getFormsInfo(filter, (error, data) => {
if (error) {
console.log('formProvider getFormsInfo, error:' + JSON.stringify(error));
} else {
console.log('formProvider getFormsInfo, data:' + JSON.stringify(data));
return;
}
console.log('formProvider getFormsInfo, data:' + JSON.stringify(data));
});
} catch(error) {
console.log(`catch err->${JSON.stringify(error)}`);
......@@ -274,7 +305,7 @@ Obtains the application's widget information on the device. This API uses a prom
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| filter | [formInfo.FormInfoFilter](js-apis-app-form-formInfo.md#forminfofilter) | No| Filter criterion.|
| filter | [formInfo.FormInfoFilter](js-apis-app-form-formInfo.md#forminfofilter) | No| Filter criterion. |
**Return value**
......@@ -287,7 +318,10 @@ Obtains the application's widget information on the device. This API uses a prom
| Error Code ID| Error Message|
| -------- | -------- |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
......@@ -324,15 +358,19 @@ Requests to publish a widget carrying data to the widget host. This API uses an
| Name| Type | Mandatory| Description |
| ------ | ---------------------------------------------------------------------- | ---- | ---------------- |
| want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:<br>Information about the target widget.<br>**abilityName**: ability of the target widget.<br>**parameters**:<br>'ohos.extra.param.key.form_dimension'<br>'ohos.extra.param.key.form_name'<br>'ohos.extra.param.key.module_name' |
| formBindingData.FormBindingData | [FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | Yes | Data used for creating the widget.|
| formBindingData.FormBindingData | [FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | Yes | Data used for creating the widget.|
| callback | AsyncCallback&lt;string&gt; | Yes| Callback used to return the widget ID.|
**Error codes**
| Error Code ID| Error Message|
| -------- | -------- |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
......@@ -351,9 +389,9 @@ try {
formProvider.requestPublishForm(want, obj, (error, data) => {
if (error) {
console.log('formProvider requestPublishForm, error: ' + JSON.stringify(error));
} else {
console.log('formProvider requestPublishForm, form ID is: ' + JSON.stringify(data));
return;
}
console.log('formProvider requestPublishForm, form ID is: ' + JSON.stringify(data));
});
} catch (error) {
console.log(`catch err->${JSON.stringify(error)}`);
......@@ -381,8 +419,12 @@ Requests to publish a widget to the widget host. This API uses an asynchronous c
| Error Code ID| Error Message|
| -------- | -------- |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
......@@ -399,9 +441,9 @@ try {
formProvider.requestPublishForm(want, (error, data) => {
if (error) {
console.log('formProvider requestPublishForm, error: ' + JSON.stringify(error));
} else {
console.log('formProvider requestPublishForm, form ID is: ' + JSON.stringify(data));
return;
}
console.log('formProvider requestPublishForm, form ID is: ' + JSON.stringify(data));
});
} catch (error) {
console.log(`catch err->${JSON.stringify(error)}`);
......@@ -424,7 +466,7 @@ Requests to publish a widget to the widget host. This API uses a promise to retu
| Name | Type | Mandatory| Description |
| --------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:<br>Information about the target widget.<br>**abilityName**: ability of the target widget.<br>**parameters**:<br>'ohos.extra.param.key.form_dimension'<br>'ohos.extra.param.key.form_name'<br>'ohos.extra.param.key.module_name' |
| formBindingData.FormBindingData | [FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | No | Data used for creating the widget. |
| formBindingData.FormBindingData | [FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | No | Data used for creating the widget. By default, no value is passed, indicating that no data is provided. |
**Return value**
......@@ -436,8 +478,12 @@ Requests to publish a widget to the widget host. This API uses a promise to retu
| Error Code ID| Error Message|
| -------- | -------- |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
| 16500050 | An IPC connection error happened. |
| 16500100 | Failed to obtain the configuration information. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
......@@ -477,6 +523,16 @@ Checks whether a widget can be published to the widget host. This API uses an as
| ------ | ------ | ---- | ------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return whether the widget can be published to the widget host.|
**Error codes**
| Error Code ID| Error Message|
| -------- | -------- |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
| 16500050 | An IPC connection error happened. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
```ts
......@@ -530,6 +586,15 @@ Checks whether a widget can be published to the widget host. This API uses a pro
| :------------ | :---------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return whether the widget can be published to the widget host.|
**Error codes**
| Error Code ID| Error Message|
| -------- | -------- |
| 202 | The application is not a system application. |
| 16500050 | An IPC connection error happened. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).||
**Example**
```ts
......
......@@ -9,6 +9,12 @@ You can use the APIs of this module to start FormExtensionAbilities.
> 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.
> The APIs of this module can be used only in the stage model.
## Modules to Import
```ts
import common from '@ohos.app.ability.common';
```
## Usage
Before using the **ServiceExtensionContext** module, you must first obtain a **FormExtensionAbility** instance.
......@@ -18,7 +24,7 @@ import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
import formBindingData from '@ohos.app.form.formBindingData';
export default class MyFormExtensionAbility extends FormExtensionAbility {
onAddForm() {
let formContext = this.context; // 获取FormExtensionContext
let formContext = this.context; // »ñÈ¡FormExtensionContext
// ...
let dataObj1 = {
temperature:'11c',
......@@ -40,6 +46,18 @@ Starts an ability. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.Form
**Error codes**
| ID| Error Message|
| -------- | -------- |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
| 16500050 | An IPC connection error happened. |
| 16500100 | Failed to obtain the configuration information. |
| 16500101 | The application is not a system application. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Parameters**
| Name| Type | Mandatory| Description |
......@@ -60,7 +78,7 @@ let want = {
uri: 'key={true,true,false}',
parameters: {}
};
this.context.startAbility(want, (error, data) => {
this.context.startAbility(want, (error) => {
if (error) {
console.log('FormExtensionContext startAbility, error:' + JSON.stringify(error));
} else {
......@@ -91,6 +109,18 @@ Starts an ability. This API uses a promise to return the result.
| ------------ | ---------------------------------- |
| Promise&lt;void&lt; | Promise that returns no value.|
**Error codes**
| ID| Error Message|
| -------- | -------- |
| 202 | The application is not a system application. |
| 401 | If the input parameter is not valid parameter. |
| 16500050 | An IPC connection error happened. |
| 16500100 | Failed to obtain the configuration information. |
| 16500101 | The application is not a system application. |
| 16501000 | An internal functional error occurred. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册