未验证 提交 327e710e 编写于 作者: O openharmony_ci 提交者: Gitee

!8287 翻译完成:6836+7117+7086+7653+7916+7761+7628+7396+7916+6963+7484 Ability APIs

Merge pull request !8287 from wusongqing/TR6836
# wantConstant
The **wantConstant** module provides the action, entity, and flags used in **Want** objects.
The **wantConstant** module provides the actions, entities, and flags used in **Want** objects.
> **NOTE**
>
......@@ -23,15 +23,15 @@ Enumerates the action constants of the **Want** object.
| ACTION_HOME | ohos.want.action.home | Action of returning to the home page. |
| ACTION_DIAL | ohos.want.action.dial | Action of launching the numeric keypad. |
| ACTION_SEARCH | ohos.want.action.search | Action of launching the search function. |
| ACTION_WIRELESS_SETTINGS | ohos.settings.wireless | Action of launching the UI that provides radio network settings, for example, Wi-Fi option. |
| ACTION_WIRELESS_SETTINGS | ohos.settings.wireless | Action of launching the UI that provides wireless network settings, for example, Wi-Fi options. |
| ACTION_MANAGE_APPLICATIONS_SETTINGS | ohos.settings.manage.applications | Action of launching the UI for managing installed applications. |
| ACTION_APPLICATION_DETAILS_SETTINGS | ohos.settings.application.details | Action of launching the UI that displays the details of an application. |
| ACTION_SET_ALARM | ohos.want.action.setAlarm | Action of launching the UI for setting the alarm clock. |
| ACTION_SHOW_ALARMS | ohos.want.action.showAlarms | Action of launching the UI that displays all clock alarms. |
| ACTION_SHOW_ALARMS | ohos.want.action.showAlarms | Action of launching the UI that displays all alarms. |
| ACTION_SNOOZE_ALARM | ohos.want.action.snoozeAlarm | Action of launching the UI for snoozing an alarm. |
| ACTION_DISMISS_ALARM | ohos.want.action.dismissAlarm | Action of launching the UI for deleting an alarm. |
| ACTION_DISMISS_TIMER | ohos.want.action.dismissTimer | Action of launching the UI for dismissing a timer. |
| ACTION_SEND_SMS | ohos.want.action.sendSms | Action of launching the UI for sending an SMS. |
| ACTION_SEND_SMS | ohos.want.action.sendSms | Action of launching the UI for sending an SMS message. |
| ACTION_CHOOSE | ohos.want.action.choose | Action of launching the UI for openning a contact or picture. |
| ACTION_IMAGE_CAPTURE<sup>8+</sup> | ohos.want.action.imageCapture | Action of launching the UI for photographing. |
| ACTION_VIDEO_CAPTURE<sup>8+</sup> | ohos.want.action.videoCapture | Action of launching the UI for shooting a video. |
......
......@@ -19,7 +19,7 @@ import AbilityContext from '@ohos.application.Ability'
let context = this.context.createBundleContext(test);
}
}
```
```
## Attributes
......@@ -53,15 +53,15 @@ Creates a context for a given application.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Application bundle name.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Application bundle name.|
**Return value**
| Type| Description|
| -------- | -------- |
| Context | Context created.|
| Type| Description|
| -------- | -------- |
| Context | Context created.|
**Example**
......@@ -87,15 +87,15 @@ Creates a context for a given HAP.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| moduleName | string | Yes| HAP name in the application.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| moduleName | string | Yes| HAP name in the application.|
**Return value**
| Type| Description|
| -------- | -------- |
| Context | Context created.|
| Type| Description|
| -------- | -------- |
| Context | Context created.|
**Example**
......@@ -123,16 +123,16 @@ Creates a context for a given HAP in an application.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Application bundle name.|
| moduleName | string | Yes| HAP name in the application.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Application bundle name.|
| moduleName | string | Yes| HAP name in the application.|
**Return value**
| Type| Description|
| -------- | -------- |
| Context | Context created.|
| Type| Description|
| -------- | -------- |
| Context | Context created.|
**Example**
......
......@@ -22,9 +22,9 @@ Checks whether this application is undergoing a stability test. This API uses an
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | No| Callback used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | No| Callback used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
**Example**
......@@ -46,9 +46,9 @@ Checks whether this application is undergoing a stability test. This API uses a
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
| Type| Description|
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
**Example**
......@@ -72,9 +72,9 @@ Checks whether this application is running on a RAM constrained device. This API
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
| Type| Description|
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
**Example**
......@@ -96,9 +96,9 @@ Checks whether this application is running on a RAM constrained device. This API
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | No| Callback used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | No| Callback used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
**Example**
......@@ -119,9 +119,9 @@ Obtains the memory size of this application. This API uses a promise to return t
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;number&gt; | Size of the application memory.|
| Type| Description|
| -------- | -------- |
| Promise&lt;number&gt; | Size of the application memory.|
**Example**
......@@ -143,9 +143,9 @@ Obtains the memory size of this application. This API uses an asynchronous callb
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;number&gt; | No| Size of the application memory.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;number&gt; | No| Size of the application memory.|
**Example**
......@@ -155,7 +155,11 @@ Obtains the memory size of this application. This API uses an asynchronous callb
console.log('startAbility result success:' + JSON.stringify(data));
})
```
## appManager.getProcessRunningInfos<sup>8+</sup>
## appManager.getProcessRunningInfos<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [appManager.getProcessRunningInformation<sup>9+</sup>](#appmanagergetprocessrunninginformation9) instead.
getProcessRunningInfos(): Promise\<Array\<ProcessRunningInfo>>;
......@@ -181,7 +185,11 @@ Obtains information about the running processes. This API uses a promise to retu
});
```
## appManager.getProcessRunningInfos<sup>8+</sup>
## appManager.getProcessRunningInfos<sup>(deprecated)</sup>
> **NOTE**
>
> This API is deprecated since API version 9. You are advised to use [appManager.getProcessRunningInformation<sup>9+</sup>](#appmanagergetprocessrunninginformation9-1) instead.
getProcessRunningInfos(callback: AsyncCallback\<Array\<ProcessRunningInfo>>): void;
......@@ -206,11 +214,62 @@ Obtains information about the running processes. This API uses an asynchronous c
})
```
## appManager.getProcessRunningInformation<sup>9+</sup>
getProcessRunningInformation(): Promise\<Array\<ProcessRunningInformation>>;
Obtains information about the running processes. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Return value**
| Type| Description|
| -------- | -------- |
| Promise\<Array\<ProcessRunningInformation>> | Promise used to return the process information.|
**Example**
```js
app.getProcessRunningInformation().then((data) => {
console.log('success:' + JSON.stringify(data));
}).catch((error) => {
console.log('failed:' + JSON.stringify(error));
});
```
## appManager.getProcessRunningInformation<sup>9+</sup>
getProcessRunningInformation(callback: AsyncCallback\<Array\<ProcessRunningInformation>>): void;
Obtains information about the running processes. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback\<Array\<ProcessRunningInformation>> | No| Callback used to return the process information.|
**Example**
```js
app.getProcessRunningInformation((err, data) => {
console.log('startAbility result failed :' + JSON.stringify(err));
console.log('startAbility result success:' + JSON.stringify(data));
})
```
## appManager.registerApplicationStateObserver<sup>8+</sup>
registerApplicationStateObserver(observer: ApplicationStateObserver): number;
Registers the application state observer.
Registers an observer to listen for the state of all applications.
**Required permissions**: ohos.permission.RUNNING_STATE_OBSERVER
......@@ -222,7 +281,7 @@ Registers the application state observer.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| observer | ApplicationStateObserver | No| Numeric code of the observer.|
| observer | [ApplicationStateObserver](#applicationstateobserver) | No| Numeric code of the observer.|
**Example**
......@@ -244,6 +303,48 @@ Registers the application state observer.
const observerCode = app.registerApplicationStateObserver(applicationStateObserver);
console.log('-------- observerCode: ---------', observerCode);
```
## appManager.registerApplicationStateObserver<sup>9+</sup>
registerApplicationStateObserver(observer: ApplicationStateObserver, bundleNameList: Array<string>): number;
Registers an observer to listen for the state of a specified application.
**Required permissions**: ohos.permission.RUNNING_STATE_OBSERVER
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| observer | [ApplicationStateObserver](#applicationstateobserver) | No| Numeric code of the observer.|
| bundleNameList | Array<string> | No| **bundleName** array to be registered for listening. The maximum value is 128.|
**Example**
```js
var applicationStateObserver = {
onForegroundApplicationChanged(appStateData) {
console.log('------------ onForegroundApplicationChanged -----------', appStateData);
},
onAbilityStateChanged(abilityStateData) {
console.log('------------ onAbilityStateChanged -----------', abilityStateData);
},
onProcessCreated(processData) {
console.log('------------ onProcessCreated -----------', processData);
},
onProcessDied(processData) {
console.log('------------ onProcessDied -----------', processData);
}
}
var bundleNameList = ['bundleName1', 'bundleName2'];
const observerCode = app.registerApplicationStateObserver(applicationStateObserver, bundleNameList);
console.log('-------- observerCode: ---------', observerCode);
```
## appManager.unregisterApplicationStateObserver<sup>8+</sup>
......@@ -258,7 +359,7 @@ Deregisters the application state observer. This API uses an asynchronous callba
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| observerId | number | No| Numeric code of the observer.|
......@@ -319,7 +420,7 @@ Deregisters the application state observer. This API uses a promise to return th
getForegroundApplications(callback: AsyncCallback\<Array\<AppStateData>>): void;
Obtains applications that run in the foreground. This API uses an asynchronous callback to return the result.
Obtains applications that are running in the foreground. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
......@@ -350,7 +451,7 @@ Obtains applications that run in the foreground. This API uses an asynchronous c
getForegroundApplications(): Promise\<Array\<AppStateData>>;
Obtains applications that run in the foreground. This API uses a promise to return the result.
Obtains applications that are running in the foreground. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
......@@ -380,7 +481,7 @@ Obtains applications that run in the foreground. This API uses a promise to retu
killProcessWithAccount(bundleName: string, accountId: number): Promise\<void\>
Kills the process by bundle name and account ID. This API uses a promise to return the result.
Kills a process by bundle name and account ID. This API uses a promise to return the result.
**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS and ohos.permission.CLEAN_BACKGROUND_PROCESSES
......@@ -390,10 +491,10 @@ Kills the process by bundle name and account ID. This API uses a promise to retu
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Bundle name of an application.|
| accountId | number | Yes| Account ID.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Bundle name of an application.|
| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
**Example**
......@@ -414,7 +515,7 @@ app.killProcessWithAccount(bundleName, accountId)
killProcessWithAccount(bundleName: string, accountId: number, callback: AsyncCallback\<void\>): void
Kills the process by bundle name and account ID. This API uses an asynchronous callback to return the result.
Kills a process by bundle name and account ID. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -424,11 +525,11 @@ Kills the process by bundle name and account ID. This API uses an asynchronous c
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Bundle name of an application.|
| accountId | number | Yes| Account ID.|
| callback | AsyncCallback\<void\> | Yes| Callback used to return the result.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Bundle name of an application.|
| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
| callback | AsyncCallback\<void\> | Yes| Callback used to return the result.|
**Example**
......@@ -708,7 +809,7 @@ console.log('-------- processDiedInfo: ---------', processDiedInfo);
| bundleName<sup>8+</sup> | string | Yes | No | Bundle name of an application. |
| abilityName<sup>8+</sup> | string | Yes | No | Ability name. |
| uid<sup>8+</sup> | number | Yes | No | User ID. |
| state<sup>8+</sup> | number | Yes | No | Application information. |
| state<sup>8+</sup> | number | Yes | No | Ability state. |
| moduleName<sup>9+</sup> | string | Yes | No | Name of the HAP file to which the ability belongs. |
| abilityType<sup>8+</sup> | string | Yes | No | Ability type. |
......@@ -736,3 +837,16 @@ console.log('-------- processDiedInfo: ---------', processDiedInfo);
| uid<sup>9+</sup> | Read only | number | No | User ID.|
| processName<sup>9+</sup> | Read only | string | No | Process name.|
| bundleNames<sup>9+</sup> | Read only | Array\<string> | No | **bundleName** array in the running processes.|
## ApplicationStateObserver
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Readable| Writable| Description |
| ----------------------- | ---------| ---- | ---- | ------------------------- |
| [onForegroundApplicationChanged<sup>8+</sup>](#applicationstateobserveronforegroundapplicationchanged8) | AsyncCallback\<void> | Yes | No | Callback invoked when the foreground or background state of an application changes. |
| [onAbilityStateChanged<sup>8+</sup>](#applicationstateobserveronabilitystatechanged8) | AsyncCallback\<void> | Yes | No | Callback invoked when the ability state changes. |
| [onProcessCreated<sup>8+</sup>](#applicationstateobserveronprocesscreated8) | AsyncCallback\<void> | Yes | No | Callback invoked when a process is created. |
| [onProcessDied<sup>8+</sup>](#applicationstateobserveronprocessdied8) | AsyncCallback\<void> | Yes | No | Callback invoked when a process is destroyed. |
......@@ -119,7 +119,7 @@ helper.on(
off(type: 'dataChange', uri: string, callback?: AsyncCallback\<void>): void
Unregisters the observer used to observe data specified by a given URI. This API uses an asynchronous callback to return the result.
Deregisters the observer used to observe data specified by a given URI. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
......@@ -647,7 +647,7 @@ Deletes one or more data records from the database. This API uses an asynchronou
```js
import featureAbility from '@ohos.ability.featureAbility'
import ohos_data_ability from '@ohos.data.dataability'
import ohos_data_ability from '@ohos.data.dataAbility'
var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility"
);
......@@ -662,7 +662,7 @@ DAHelper.delete(
## DataAbilityHelper.delete
delete(uri: string, predicates: dataAbility.DataAbilityPredicates): Promise\<number>
delete(uri: string, predicates?: dataAbility.DataAbilityPredicates): Promise\<number>;
Deletes one or more data records from the database. This API uses a promise to return the result.
......@@ -685,7 +685,7 @@ Deletes one or more data records from the database. This API uses a promise to r
```js
import featureAbility from '@ohos.ability.featureAbility'
import ohos_data_ability from '@ohos.data.dataability'
import ohos_data_ability from '@ohos.data.dataAbility'
var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility"
);
......@@ -719,7 +719,7 @@ Updates data records in the database. This API uses an asynchronous callback to
```js
import featureAbility from '@ohos.ability.featureAbility'
import ohos_data_ability from '@ohos.data.dataability'
import ohos_data_ability from '@ohos.data.dataAbility'
var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility"
);
......@@ -741,7 +741,7 @@ DAHelper.update(
## DataAbilityHelper.update
update(uri: string, valuesBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates): Promise\<number>
update(uri: string, valuesBucket: rdb.ValuesBucket, predicates?: dataAbility.DataAbilityPredicates): Promise\<number>;
Updates data records in the database. This API uses a promise to return the result.
......@@ -765,7 +765,7 @@ Updates data records in the database. This API uses a promise to return the resu
```js
import featureAbility from '@ohos.ability.featureAbility'
import ohos_data_ability from '@ohos.data.dataability'
import ohos_data_ability from '@ohos.data.dataAbility'
var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility"
);
......@@ -806,7 +806,7 @@ Queries data in the database. This API uses an asynchronous callback to return t
```js
import featureAbility from '@ohos.ability.featureAbility'
import ohos_data_ability from '@ohos.data.dataability'
import ohos_data_ability from '@ohos.data.dataAbility'
var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility"
);
......@@ -825,7 +825,7 @@ DAHelper.query(
## DataAbilityHelper.query
query(uri: string, columns: Array\<string>, predicates: dataAbility.DataAbilityPredicates): Promise\<ResultSet>
query(uri: string, columns?: Array\<string>, predicates?: dataAbility.DataAbilityPredicates): Promise\<ResultSet>;
Queries data in the database. This API uses a promise to return the result.
......@@ -849,7 +849,7 @@ Queries data in the database. This API uses a promise to return the result.
```js
import featureAbility from '@ohos.ability.featureAbility'
import ohos_data_ability from '@ohos.data.dataability'
import ohos_data_ability from '@ohos.data.dataAbility'
var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility"
);
......@@ -876,7 +876,7 @@ Calls the extended API of the Data ability. This API uses a promise to return th
| Name | Type | Mandatory| Description |
| ---------- | --------------------------------- | ---- | ------------------------------------------------ |
| uri | string | Yes | URI of the Data ability. Example: "dataability:///com.example.xxx.xxxx" |
| uri | string | Yes | URI of the Data ability. Example: "dataability:///com.example.xxx.xxxx". |
| method | string | Yes | Name of the API to call. |
| arg | string | Yes |Parameter to pass. |
| extras | [PacMap](#pacmap) | Yes | Key-value pair parameter. |
......@@ -912,7 +912,7 @@ Calls the extended API of the Data ability. This API uses an asynchronous callba
| Name | Type | Mandatory| Description |
| ---------- | --------------------------------- | ---- | ------------------------------------------------ |
| uri | string | Yes | URI of the Data ability. Example: "dataability:///com.example.xxx.xxxx" |
| uri | string | Yes | URI of the Data ability. Example: "dataability:///com.example.xxx.xxxx". |
| method | string | Yes | Name of the API to call. |
| arg | string | Yes |Parameter to pass. |
| extras | [PacMap](#pacmap) | Yes | Key-value pair parameter. |
......@@ -932,8 +932,107 @@ dataAbilityHelper.call("dataability:///com.example.jsapidemo.UserDataAbility", "
console.info('Operation succeeded: ' + data);
});
```
## DataAbilityHelper.executeBatch
executeBatch(uri: string, operations: Array\<DataAbilityOperation>, callback: AsyncCallback\<Array\<DataAbilityResult>>): void;
Operates data in the database. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | --------------------------------- | ---- | ------------------------------------------------ |
| uri | string | Yes | URI of the Data ability. Example: "dataability:///com.example.xxx.xxxx".|
| operations | Array\<[DataAbilityOperation](#dataabilityoperation)> | Yes | A list of data operations on the database. |
| callback | AsyncCallback\<Array\<[DataAbilityResult](#dataabilityresult)>> | Yes |Callback used to return the result of each operation in the **DataAbilityResult** array. |
**Example**
```js
import featureAbility from '@ohos.ability.featureAbility';
// Select the operations to be performed on the database according to the DataAbilityOperation array.
let op=new Array();
let dataAbilityHelper = featureAbility.acquireDataAbilityHelper("dataability:///com.example.jsapidemo.UserDataAbility");
dataAbilityHelper.executeBatch("dataability:///com.example.jsapidemo.UserDataAbility", op, (err, data) => {
if (err) {
console.error('Operation failed. Cause: ' + err);
return;
}
console.info('Operation succeeded: ' + data);
});
```
## DataAbilityHelper.executeBatch
executeBatch(uri: string, operations: Array\<DataAbilityOperation>): Promise\<Array\<DataAbilityResult>>;
Operates data in the database. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | -------------------------------| ---- | ------------------------------------------------ |
| uri | string | Yes | URI of the Data ability. Example: "dataability:///com.example.xxx.xxxx".|
| operations | Array\<[DataAbilityOperation](#dataabilityoperation)> | Yes | A list of data operations on the database. |
**Return value**
| Type| Description|
|------ | ------- |
|Promise\<Array\<[DataAbilityResult](#dataabilityresult)>> | Promise used to return the result of each operation in the **DataAbilityResult** array.|
**Example**
```js
import featureAbility from '@ohos.ability.featureAbility';
// Select the operations to be performed on the database according to the DataAbilityOperation array.
let op=new Array();
let dataAbilityHelper = featureAbility.acquireDataAbilityHelper("dataability:///com.example.jsapidemo.UserDataAbility");
dataAbilityHelper.executeBatch("dataability:///com.example.jsapidemo.UserDataAbility",op ).then((data) => {
console.info('Operation succeeded: ' + data);
}).catch((error) => {
console.error('Operation failed. Cause: ' + error);
});
```
## PacMap
[key: string]: number | string | boolean | Array\<string | number | boolean> | null;
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
| Name| Type| Mandatory| Description|
| ------ | ------ | ------ | ------ |
| [key: string] | number \| string \| boolean \| Array\<string \| number \| boolean\> \| null | Yes| Data stored in key-value pairs.|
## DataAbilityOperation
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
| Name | Type | Readable | Writable | Mandatory| Description |
| -------- | -------- | -------- | -------- | --------| -------- |
| uri | string | Yes | No | Yes | URI of the Data ability. Example: "dataability:///com.example.xxx.xxxx". |
| type | featureAbility.DataAbilityOperationType | Yes | No | Yes | Operation type. |
| valuesBucket? | rdb.ValuesBucket | Yes | No | No | Data value to set. |
| valueBackReferences? | rdb.ValuesBucket | Yes | No | No | **ValuesBucket** object that contains a set of key-value pairs. |
| predicates? | dataAbility.DataAbilityPredicates | Yes | No | No | Predicates to set. If no predicate is set, all data records are displayed. |
| predicatesBackReferences? | Map\<number, number> | Yes | No | No | Back references of the predicates. |
| interrupted? | boolean | Yes | No | No | Whether batch operations can be interrupted. |
| expectedCount? | number | Yes | No | No | Expected number of rows to be updated or deleted. |
## DataAbilityResult
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
| Name | Type | Readable | Writable | Mandatory | Description |
| -------- | -------- | -------- | -------- | -------- | -------- |
| uri? | string | Yes | No | No | URI of the Data ability. Example: "dataability:///com.example.xxx.xxxx". |
| count? | number | Yes | No | No | Number of rows affected by the operation. |
# ErrorManager
The **ErrorManager** module provides APIs for registering and deregistering error observers.
> **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
```
import errorManager from '@ohos.application.errorManager'
```
## ErrorManager.registerErrorObserver
registerErrorObserver(observer: ErrorObserver): number;
Registers an error observer.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| observer | [ErrorObserver](#errorobserver) | No| Numeric code of the observer.|
**Example**
```js
var observer = {
onUnhandledException(errorMsg) {
console.log('onUnhandledException, errorMsg: ', errorMsg)
}
}
errorManager.registerErrorObserver(observer)
.then((data) => {
console.log('----------- registerErrorObserver success ----------', data);
})
.catch((err) => {
console.log('----------- registerErrorObserver fail ----------', err);
})
```
## ErrorManager.unregisterErrorObserver
unregisterErrorObserver(observerId: number, callback: AsyncCallback\<void>): void;
Deregisters an error observer. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| observerId | number | No| Numeric code of the observer.|
| callback | AsyncCallback\<void> | No| Callback used to return the result.|
**Example**
```js
var observerId = 100;
function unregisterErrorObserverCallback(err) {
if (err) {
console.log('------------ unregisterErrorObserverCallback ------------', err);
}
}
errorManager.unregisterErrorObserver(observerId, unregisterErrorObserverCallback);
```
## ErrorManager.unregisterErrorObserver
unregisterErrorObserver(observerId: number): Promise\<void>;
Deregisters an error observer. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| observerId | number | No| Numeric code of the observer.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```js
var observerId = 100;
errorManager.unregisterErrorObserver(observerId)
.then((data) => {
console.log('----------- unregisterErrorObserver success ----------', data);
})
.catch((err) => {
console.log('----------- unregisterErrorObserver fail ----------', err);
})
```
## ErrorObserver
onUnhandledException(errMsg: string): void;
Called when an unhandled exception occurs in the JS runtime.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| errMsg | string | No| Message and error stack trace about the exception.|
**Example**
```js
var observer = {
onUnhandledException(errorMsg) {
console.log('onUnhandledException, errorMsg: ', errorMsg)
}
}
errorManager.registerErrorObserver(observer)
.then((data) => {
console.log('----------- registerErrorObserver success ----------', data);
})
.catch((err) => {
console.log('----------- registerErrorObserver fail ----------', err);
})
```
......@@ -35,15 +35,15 @@ Called to notify the widget provider that a **Form** instance (widget) has been
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | -------------------------------------- | ---- | ------------------------------------------------------------ |
| 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.|
| Name| Type | Mandatory| Description |
| ------ | -------------------------------------- | ---- | ------------------------------------------------------------ |
| 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**
| Type | Description |
| ------------------------------------------------------------ | ----------------------------------------------------------- |
| [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | A **formBindingData.FormBindingData** object containing the data to be displayed on the widget.|
| Type | Description |
| ------------------------------------------------------------ | ----------------------------------------------------------- |
| [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | A **formBindingData.FormBindingData** object containing the data to be displayed on the widget.|
**Example**
......@@ -72,9 +72,9 @@ Called to notify the widget provider that a temporary widget has been converted
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------ |
| formId | string | Yes | ID of the widget that requests to be converted to a normal one.|
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------ |
| formId | string | Yes | ID of the widget that requests to be converted to a normal one.|
**Example**
......@@ -96,9 +96,9 @@ Called to notify the widget provider that a widget has been updated. After obtai
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------ |
| formId | string | Yes | ID of the widget that requests to be updated.|
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------ |
| formId | string | Yes | ID of the widget that requests to be updated.|
**Example**
......@@ -127,9 +127,9 @@ Called to notify the widget provider of the change of visibility.
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ------------------------- | ---- | ---------------------------- |
| newStatus | { [key: string]: number } | Yes | ID and visibility status of the widget to be changed.|
| Name | Type | Mandatory| Description |
| --------- | ------------------------- | ---- | ---------------------------- |
| newStatus | { [key: string]: number } | Yes | ID and visibility status of the widget to be changed.|
**Example**
......@@ -162,10 +162,10 @@ Called to instruct the widget provider to receive and process the widget event.
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------ | ---- | ---------------------- |
| formId | string | Yes | ID of the widget that requests the event.|
| message | string | Yes | Event message. |
| Name | Type | Mandatory| Description |
| ------- | ------ | ---- | ---------------------- |
| formId | string | Yes | ID of the widget that requests the event.|
| message | string | Yes | Event message. |
**Example**
......@@ -187,9 +187,9 @@ Called to notify the widget provider that a **Form** instance (widget) has been
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------ |
| formId | string | Yes | ID of the widget to be destroyed.|
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------ |
| formId | string | Yes | ID of the widget to be destroyed.|
**Example**
......@@ -211,9 +211,9 @@ Called when the configuration of the environment where the ability is running is
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| config | [Configuration](js-apis-configuration.md) | Yes| New configuration.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| config | [Configuration](js-apis-configuration.md) | Yes| New configuration.|
**Example**
......@@ -235,9 +235,9 @@ Called when the widget provider receives the status query result of a widget. By
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | No| Description of the widget state, including the bundle name, ability name, module name, widget name, and widget dimension.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | No| Description of the widget state, including the bundle name, ability name, module name, widget name, and widget dimension.|
**Example**
......@@ -250,3 +250,40 @@ Called when the widget provider receives the status query result of a widget. By
}
}
```
## FormExtension.onShare
onShare?(formId: string): {[key: string]: any};
Called by the widget provider to receive shared widget data.
This is a system API.
**System capability**: SystemCapability.Ability.Form
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| formId | string | Yes | ID of a widget.|
**Return value**
| Type | Description |
| ------------------------------------------------------------ | ----------------------------------------------------------- |
| {[key: string]: any} | Data to be shared by the widget, in the form of key-value pairs.|
**Example**
```js
class MyFormExtension extends FormExtension {
onShare(formId) {
console.log('FormExtension onShare, formId:' + formId);
let wantParams = {
"temperature":"20",
"time":"2022-8-8 09:59",
};
return wantParams;
}
}
```
......@@ -2,13 +2,32 @@
The **FormExtensionContext** module, inherited from **ExtensionContext**, provides context for Form Extension abilities.
You can use the APIs of this module to start abilities.
You can use the APIs of this module to start Form Extension abilities.
> **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.
> The APIs of this module can be used only in the stage model.
## Usage
Before using the **ServiceExtensionContext** module, you must first obtain a **FormExtension** instance.
```js
import FormExtension from '@ohos.application.FormExtension';
import formBindingData from '@ohos.application.formBindingData'
export default class MyFormExtension extends FormExtension {
onCreate() {
let dataObj1 = {
temperature:"11c",
"time":"11:00"
};
let obj1 = formBindingData.createFormBindingData(dataObj1);
return obj1;
}
}
```
## FormExtensionContext.startAbility
startAbility(want: Want, callback: AsyncCallback&lt;void&gt;): void
......@@ -64,7 +83,7 @@ Starts an ability. This API uses a promise to return the result.
| Type | Description |
| ------------ | ---------------------------------- |
| Promise\<void> | Promise used to return the result.|
| Promise&lt;void&lt; | Promise used to return the result.|
**Example**
......
......@@ -189,6 +189,7 @@ Obtains the application's widget information that meets a filter criterion on th
**Example**
```js
import formInfo from '@ohos.application.formInfo';
const filter : formInfo.FormInfoFilter = {
moduleName : "entry"
};
......@@ -224,6 +225,7 @@ Obtains the application's widget information on the device. This API uses a prom
**Example**
```js
import formInfo from '@ohos.application.formInfo';
const filter : formInfo.FormInfoFilter = {
moduleName : "entry"
};
......@@ -236,13 +238,13 @@ formProvider.getFormsInfo(filter).then((data) => {
## requestPublishForm<sup>9+</sup>
requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback&lt;string&gt;): &lt;void&gt;;
requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback\<string>): void;
Requests to publish a widget carrying data to the widget host. This API uses an asynchronous callback to return the result.
**System capability**
**System capability**: SystemCapability.Ability.Form
SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -276,13 +278,13 @@ SystemCapability.Ability.Form
## requestPublishForm<sup>9+</sup>
requestPublishForm(want: Want, callback: AsyncCallback&lt;string&gt;): &lt;void&gt;;
requestPublishForm(want: Want, callback: AsyncCallback&lt;string&gt;): void;
Requests to publish a widget to the widget host. This API uses an asynchronous callback to return the result.
**System capability**
**System capability**: SystemCapability.Ability.Form
SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -317,9 +319,9 @@ requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData
Requests to publish a widget to the widget host. This API uses a promise to return the result.
**System capability**
**System capability**: SystemCapability.Ability.Form
SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -360,6 +362,8 @@ Checks whether a widget can be published to the widget host. This API uses an as
**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 |
......@@ -402,6 +406,8 @@ Checks whether a widget can be published to the widget host. This API uses a pro
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Return value**
| Type | Description |
......
......@@ -362,6 +362,88 @@ Obtains the snapshot of a given mission. This API uses a promise to return the r
});
```
## missionManager.getLowResolutionMissionSnapShot<sup>9+</sup>
getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback\<MissionSnapshot>): void;
Obtains the low-resolution snapshot of a given mission. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.MANAGE_MISSIONS
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
| missionId | number | Yes| Mission ID.|
| callback | AsyncCallback&lt;[MissionSnapshot](js-apis-application-MissionSnapshot.md)&gt; | Yes| Callback used to return the snapshot information obtained.|
**Example**
```js
import missionManager from '@ohos.application.missionManager'
missionManager.getMissionInfos("", 10, (error, missions) => {
console.log("getMissionInfos is called, error.code = " + error.code);
console.log("size = " + missions.length);
console.log("missions = " + JSON.stringify(missions));
var id = missions[0].missionId;
missionManager.getLowResolutionMissionSnapShot("", id, (error, snapshot) => {
console.log("getLowResolutionMissionSnapShot is called, error.code = " + error.code);
console.log("bundleName = " + snapshot.ability.bundleName);
})
})
```
## missionManager.getLowResolutionMissionSnapShot<sup>9+</sup>
getLowResolutionMissionSnapShot(deviceId: string, missionId: number): Promise\<MissionSnapshot>;
Obtains the low-resolution snapshot of a given mission. This API uses a promise to return the result.
**Required permission**: ohos.permission.MANAGE_MISSIONS
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
| missionId | number | Yes| Mission ID.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;[MissionSnapshot](js-apis-application-MissionSnapshot.md)&gt; | Promise used to return the snapshot information obtained.|
**Example**
```js
import missionManager from '@ohos.application.missionManager'
var allMissions;
missionManager.getMissionInfos("",10).then(function(res){
allMissions=res;
}).catch(function(err){console.log(err);});
console.log("size = " + allMissions.length);
console.log("missions = " + JSON.stringify(allMissions));
var id = allMissions[0].missionId;
var snapshot = missionManager.getLowResolutionMissionSnapShot("", id).catch(function (err){
console.log(err);
});
```
## missionManager.lockMission
......
......@@ -23,9 +23,9 @@ None.
**System API**: This is a system API and cannot be called by third-party applications.
| Name| Type| Readable| Writable| Description|
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| context | [ServiceExtensionContext](js-apis-service-extension-context.md) | Yes| No| Service Extension context, which is inherited from **ExtensionContext**.|
| context | [ServiceExtensionContext](js-apis-service-extension-context.md) | Yes| No| Service Extension context, which is inherited from **ExtensionContext**.|
## ServiceExtensionAbility.onCreate
......@@ -40,9 +40,9 @@ Called when a Service Extension ability is created to initialize the service log
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information related to this Service Extension ability, including the ability name and bundle name.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information related to this Service Extension ability, including the ability name and bundle name.|
**Example**
......@@ -88,10 +88,10 @@ Called after **onCreate** is invoked when a Service Extension ability is started
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information related to this Service Extension ability, including the ability name and bundle name.|
| startId | number | Yes| Number of ability start times. The initial value is **1**, and the value is automatically incremented for each ability started.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information related to this Service Extension ability, including the ability name and bundle name.|
| startId | number | Yes| Number of ability start times. The initial value is **1**, and the value is automatically incremented for each ability started.|
**Example**
......@@ -116,15 +116,15 @@ Called after **onCreate** is invoked when a Service Extension ability is started
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md)| Yes| Information related to this Service Extension ability, including the ability name and bundle name.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md)| Yes| Information related to this Service Extension ability, including the ability name and bundle name.|
**Return value**
| Type| Description|
| -------- | -------- |
| rpc.RemoteObject | A **RemoteObject** object used for communication with the client.|
| Type| Description|
| -------- | -------- |
| rpc.RemoteObject | A **RemoteObject** object used for communication with the client.|
**Example**
......@@ -158,9 +158,9 @@ Called when this Service Extension ability is disconnected.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want |[Want](js-apis-application-Want.md)| Yes| Information related to this Service Extension ability, including the ability name and bundle name.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want |[Want](js-apis-application-Want.md)| Yes| Information related to this Service Extension ability, including the ability name and bundle name.|
**Example**
......@@ -184,16 +184,16 @@ Called when this Service Extension ability is reconnected.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want |[Want](js-apis-application-Want.md)| Yes| Information related to this Service Extension ability, including the ability name and bundle name.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want |[Want](js-apis-application-Want.md)| Yes| Information related to this Service Extension ability, including the ability name and bundle name.|
**Example**
```js
class ServiceExt extends ServiceExtension {
onDisconnect(want) {
console.log('onDisconnect, want:' + want.abilityName);
onReconnect(want) {
console.log('onReconnect, want:' + want.abilityName);
}
}
```
......@@ -202,7 +202,7 @@ Called when this Service Extension ability is reconnected.
onConfigurationUpdated(config: Configuration): void;
Called when the configuration of this Service Extension ability is updated.
Called when the configuration of this Service Extension ability is updated.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -210,9 +210,9 @@ Called when the configuration of this Service Extension ability is updated.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| config | [Configuration](js-apis-configuration.md) | Yes| New configuration.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| config | [Configuration](js-apis-configuration.md) | Yes| New configuration.|
**Example**
......@@ -236,9 +236,9 @@ Dumps the client information.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| params | Array\<string> | Yes| Parameters in the form of a command.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| params | Array\<string> | Yes| Parameters in the form of a command.|
**Example**
......
......@@ -26,7 +26,7 @@ Before using the **ServiceExtensionContext** module, you must define a child cla
startAbility(want: Want, callback: AsyncCallback&lt;void&gt;): void;
Starts an ability. This API uses a callback to return the result.
Starts an ability. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -36,8 +36,8 @@ Starts an ability. This API uses a callback to return the result.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to start, such as the ability name and bundle name.|
| callback | AsyncCallback&lt;void&gt; | No| Callback used to return the result indicating whether the API is successfully called.|
| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability, such as the ability name and bundle name.|
| callback | AsyncCallback&lt;void&gt; | No| Callback used to return the result.|
**Example**
......@@ -64,14 +64,14 @@ Starts an ability. This API uses a promise to return the result.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to start, such as the ability name and bundle name.|
| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability, such as the ability name and bundle name.|
| options | [StartOptions](js-apis-application-StartOptions.md) | Yes| Parameters used for starting the ability.|
**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**
......@@ -92,7 +92,7 @@ Starts an ability. This API uses a promise to return the result.
startAbility(want: Want, options: StartOptions, callback: AsyncCallback&lt;void&gt;): void
Starts an ability. This API uses a callback to return the result.
Starts an ability. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -102,7 +102,7 @@ Starts an ability. This API uses a callback to return the result.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.|
| options | [StartOptions](js-apis-application-StartOptions.md) | Yes| Parameters used for starting the ability.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
......@@ -136,8 +136,8 @@ Starts an ability with the account ID specified. This API uses an asynchronous c
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| accountId | number | Yes| ID of the account.|
| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.|
| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
| callback | AsyncCallback\<void\> | Yes| Callback used to return the result.|
**Example**
......@@ -169,8 +169,8 @@ Starts an ability with the account ID specified. This API uses an asynchronous c
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| accountId | number | Yes| ID of the account.|
| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.|
| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
| options | [StartOptions](js-apis-application-StartOptions.md) | No| Parameters used for starting the ability.|
| callback | AsyncCallback\<void\> | Yes| Callback used to return the result.|
......@@ -206,10 +206,16 @@ Starts an ability with the account ID specified. This API uses a promise to retu
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| accountId | number | Yes| ID of the account.|
| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.|
| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
| options | [StartOptions](js-apis-application-StartOptions.md) | No| Parameters used for starting the ability.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
......@@ -245,7 +251,7 @@ Starts a new Service Extension ability. This API uses an asynchronous callback t
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.|
| callback | AsyncCallback\<void\> | Yes| Callback used to return the result.|
**Example**
......@@ -275,7 +281,13 @@ Starts a new Service Extension ability. This API uses a promise to return the re
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
......@@ -310,8 +322,8 @@ Starts a new Service Extension ability with the account ID specified. This API u
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| accountId | number | Yes| ID of the account.|
| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.|
| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
| callback | AsyncCallback\<void\> | Yes| Callback used to return the result.|
**Example**
......@@ -344,8 +356,14 @@ Starts a new Service Extension ability with the account ID specified. This API u
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| accountId | number | Yes| ID of the account.|
| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.|
| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
......@@ -369,7 +387,7 @@ Starts a new Service Extension ability with the account ID specified. This API u
stopServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void;
Stops Service Extension abilities in the same application. This API uses an asynchronous callback to return the result.
Stops a Service Extension ability in the same application. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -379,7 +397,7 @@ Stops Service Extension abilities in the same application. This API uses an asyn
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.|
| callback | AsyncCallback\<void\> | Yes| Callback used to return the result.|
**Example**
......@@ -399,7 +417,7 @@ Stops Service Extension abilities in the same application. This API uses an asyn
stopServiceExtensionAbility(want: Want): Promise\<void>;
Stops Service Extension abilities in the same application. This API uses a promise to return the result.
Stops a Service Extension ability in the same application. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -409,7 +427,13 @@ Stops Service Extension abilities in the same application. This API uses a promi
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
......@@ -432,7 +456,7 @@ Stops Service Extension abilities in the same application. This API uses a promi
stopServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\<void>): void;
Stops Service Extension abilities in the same application with the account ID specified. This API uses an asynchronous callback to return the result.
Stops a Service Extension ability in the same application with the account ID specified. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
......@@ -444,8 +468,8 @@ Stops Service Extension abilities in the same application with the account ID sp
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| accountId | number | Yes| ID of the account.|
| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.|
| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
| callback | AsyncCallback\<void\> | Yes| Callback used to return the result.|
**Example**
......@@ -466,7 +490,7 @@ Stops Service Extension abilities in the same application with the account ID sp
stopServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\<void>;
Stops Service Extension abilities in the same application with the account ID specified. This API uses a promise to return the result.
Stops a Service Extension ability in the same application with the account ID specified. This API uses a promise to return the result.
**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
......@@ -478,8 +502,14 @@ Stops Service Extension abilities in the same application with the account ID sp
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| accountId | number | Yes| ID of the account.|
| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.|
| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
......@@ -503,7 +533,7 @@ Stops Service Extension abilities in the same application with the account ID sp
terminateSelf(callback: AsyncCallback&lt;void&gt;): void;
Terminates this ability. This API uses a callback to return the result.
Terminates this ability. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -513,7 +543,7 @@ Terminates this ability. This API uses a callback to return the result.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | No| Callback used to return the result indicating whether the API is successfully called.|
| callback | AsyncCallback&lt;void&gt; | No| Callback used to return the result.|
**Example**
......@@ -537,7 +567,7 @@ Terminates this ability. This API uses a promise to return the result.
| 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**
......@@ -563,7 +593,7 @@ Connects this ability to a Service ability.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to connect to, such as the ability name and bundle name.|
| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability, such as the ability name and bundle name.|
| options | [ConnectOptions](js-apis-featureAbility.md#connectoptions) | Yes| Callback used to return the information indicating that the connection is successful, interrupted, or failed.|
**Return value**
......@@ -601,8 +631,8 @@ Uses the **AbilityInfo.AbilityType.SERVICE** template and account ID to connect
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| accountId | number | Yes| ID of the account.|
| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability.|
| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
| options | ConnectOptions | No| Remote object instance.|
**Return value**
......@@ -633,7 +663,7 @@ Uses the **AbilityInfo.AbilityType.SERVICE** template and account ID to connect
disconnectAbility(connection: number, callback:AsyncCallback&lt;void&gt;): void;
Disconnects this ability from the Service ability. This API uses a callback to return the result.
Disconnects this ability from the Service ability. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -644,7 +674,7 @@ Disconnects this ability from the Service ability. This API uses a callback to r
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| connection | number | Yes| Number returned after **connectAbility** is called.|
| callback | AsyncCallback&lt;void&gt; | No| Callback used to return the result indicating whether the API is successfully called.|
| callback | AsyncCallback&lt;void&gt; | No| Callback used to return the result.|
**Example**
......@@ -676,7 +706,7 @@ Disconnects this ability from the Service ability. This API uses a promise to re
| 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**
......@@ -689,3 +719,41 @@ Disconnects this ability from the Service ability. This API uses a promise to re
console.log('failed:' + JSON.stringify(error));
});
```
## ServiceExtensionContext.startAbilityByCall
startAbilityByCall(want: Want): Promise&lt;Caller&gt;;
Starts an ability in the background and obtains the caller interface for communication.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability, including the ability name, module name, bundle name, and device ID. If the device ID is left blank or the default value is used, the local ability will be started.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;Caller&gt; | Promise used to return the caller object to communicate with.|
**Example**
```js
let caller = undefined;
this.context.startAbilityByCall({
bundleName: "com.example.myservice",
moduleName: "entry",
abilityName: "MainAbility",
deviceId: ""
}).then((obj) => {
caller = obj;
console.log('Caller GetCaller Get ' + caller);
}).catch((e) => {
console.log('Caller GetCaller error ' + e);
});
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册