You need to sign in or sign up before continuing.
提交 8392bad9 编写于 作者: W wusongqing

update docs against 6836+7117+7086+7653+7916+7761+7628+7396+7916+6963+7484

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 f7f19e21
# wantConstant # 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** > **NOTE**
> >
...@@ -23,15 +23,15 @@ Enumerates the action constants of the **Want** object. ...@@ -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_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_DIAL | ohos.want.action.dial | Action of launching the numeric keypad. |
| ACTION_SEARCH | ohos.want.action.search | Action of launching the search function. | | 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_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_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_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_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_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_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_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_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. | | 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' ...@@ -19,7 +19,7 @@ import AbilityContext from '@ohos.application.Ability'
let context = this.context.createBundleContext(test); let context = this.context.createBundleContext(test);
} }
} }
``` ```
## Attributes ## Attributes
...@@ -53,15 +53,15 @@ Creates a context for a given application. ...@@ -53,15 +53,15 @@ Creates a context for a given application.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Application bundle name.| | bundleName | string | Yes| Application bundle name.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Context | Context created.| | Context | Context created.|
**Example** **Example**
...@@ -87,15 +87,15 @@ Creates a context for a given HAP. ...@@ -87,15 +87,15 @@ Creates a context for a given HAP.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| moduleName | string | Yes| HAP name in the application.| | moduleName | string | Yes| HAP name in the application.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Context | Context created.| | Context | Context created.|
**Example** **Example**
...@@ -123,16 +123,16 @@ Creates a context for a given HAP in an application. ...@@ -123,16 +123,16 @@ Creates a context for a given HAP in an application.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Application bundle name.| | bundleName | string | Yes| Application bundle name.|
| moduleName | string | Yes| HAP name in the application.| | moduleName | string | Yes| HAP name in the application.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Context | Context created.| | Context | Context created.|
**Example** **Example**
......
...@@ -22,9 +22,9 @@ Checks whether this application is undergoing a stability test. This API uses an ...@@ -22,9 +22,9 @@ Checks whether this application is undergoing a stability test. This API uses an
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | 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.| | 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** **Example**
...@@ -46,9 +46,9 @@ Checks whether this application is undergoing a stability test. This API uses a ...@@ -46,9 +46,9 @@ Checks whether this application is undergoing a stability test. This API uses a
**Return value** **Return value**
| Type| Description| | 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.| | 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** **Example**
...@@ -72,9 +72,9 @@ Checks whether this application is running on a RAM constrained device. This API ...@@ -72,9 +72,9 @@ Checks whether this application is running on a RAM constrained device. This API
**Return value** **Return value**
| Type| Description| | 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.| | 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** **Example**
...@@ -96,9 +96,9 @@ Checks whether this application is running on a RAM constrained device. This API ...@@ -96,9 +96,9 @@ Checks whether this application is running on a RAM constrained device. This API
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | 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.| | 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** **Example**
...@@ -119,9 +119,9 @@ Obtains the memory size of this application. This API uses a promise to return t ...@@ -119,9 +119,9 @@ Obtains the memory size of this application. This API uses a promise to return t
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;number&gt; | Size of the application memory.| | Promise&lt;number&gt; | Size of the application memory.|
**Example** **Example**
...@@ -143,9 +143,9 @@ Obtains the memory size of this application. This API uses an asynchronous callb ...@@ -143,9 +143,9 @@ Obtains the memory size of this application. This API uses an asynchronous callb
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;number&gt; | No| Size of the application memory.| | callback | AsyncCallback&lt;number&gt; | No| Size of the application memory.|
**Example** **Example**
...@@ -155,7 +155,11 @@ Obtains the memory size of this application. This API uses an asynchronous callb ...@@ -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)); 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>>; getProcessRunningInfos(): Promise\<Array\<ProcessRunningInfo>>;
...@@ -181,7 +185,11 @@ Obtains information about the running processes. This API uses a promise to retu ...@@ -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; getProcessRunningInfos(callback: AsyncCallback\<Array\<ProcessRunningInfo>>): void;
...@@ -206,11 +214,62 @@ Obtains information about the running processes. This API uses an asynchronous c ...@@ -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> ## appManager.registerApplicationStateObserver<sup>8+</sup>
registerApplicationStateObserver(observer: ApplicationStateObserver): number; 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 **Required permissions**: ohos.permission.RUNNING_STATE_OBSERVER
...@@ -222,7 +281,7 @@ Registers the application state observer. ...@@ -222,7 +281,7 @@ Registers the application state observer.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| observer | ApplicationStateObserver | No| Numeric code of the observer.| | observer | [ApplicationStateObserver](#applicationstateobserver) | No| Numeric code of the observer.|
**Example** **Example**
...@@ -244,6 +303,48 @@ Registers the application state observer. ...@@ -244,6 +303,48 @@ Registers the application state observer.
const observerCode = app.registerApplicationStateObserver(applicationStateObserver); const observerCode = app.registerApplicationStateObserver(applicationStateObserver);
console.log('-------- observerCode: ---------', observerCode); 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> ## appManager.unregisterApplicationStateObserver<sup>8+</sup>
...@@ -258,7 +359,7 @@ Deregisters the application state observer. This API uses an asynchronous callba ...@@ -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. **System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| observerId | number | No| Numeric code of the observer.| | 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 ...@@ -319,7 +420,7 @@ Deregisters the application state observer. This API uses a promise to return th
getForegroundApplications(callback: AsyncCallback\<Array\<AppStateData>>): void; 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 **Required permissions**: ohos.permission.GET_RUNNING_INFO
...@@ -350,7 +451,7 @@ Obtains applications that run in the foreground. This API uses an asynchronous c ...@@ -350,7 +451,7 @@ Obtains applications that run in the foreground. This API uses an asynchronous c
getForegroundApplications(): Promise\<Array\<AppStateData>>; 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 **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 ...@@ -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\> 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 **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 ...@@ -390,10 +491,10 @@ Kills the process by bundle name and account ID. This API uses a promise to retu
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Bundle name of an application.| | bundleName | string | Yes| Bundle name of an application.|
| accountId | number | Yes| Account ID.| | accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
**Example** **Example**
...@@ -414,7 +515,7 @@ app.killProcessWithAccount(bundleName, accountId) ...@@ -414,7 +515,7 @@ app.killProcessWithAccount(bundleName, accountId)
killProcessWithAccount(bundleName: string, accountId: number, callback: AsyncCallback\<void\>): void 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 **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 ...@@ -424,11 +525,11 @@ Kills the process by bundle name and account ID. This API uses an asynchronous c
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Bundle name of an application.| | bundleName | string | Yes| Bundle name of an application.|
| accountId | number | Yes| Account ID.| | 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.| | callback | AsyncCallback\<void\> | Yes| Callback used to return the result.|
**Example** **Example**
...@@ -708,7 +809,7 @@ console.log('-------- processDiedInfo: ---------', processDiedInfo); ...@@ -708,7 +809,7 @@ console.log('-------- processDiedInfo: ---------', processDiedInfo);
| bundleName<sup>8+</sup> | string | Yes | No | Bundle name of an application. | | bundleName<sup>8+</sup> | string | Yes | No | Bundle name of an application. |
| abilityName<sup>8+</sup> | string | Yes | No | Ability name. | | abilityName<sup>8+</sup> | string | Yes | No | Ability name. |
| uid<sup>8+</sup> | number | Yes | No | User ID. | | 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. | | 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. | | abilityType<sup>8+</sup> | string | Yes | No | Ability type. |
...@@ -736,3 +837,16 @@ console.log('-------- processDiedInfo: ---------', processDiedInfo); ...@@ -736,3 +837,16 @@ console.log('-------- processDiedInfo: ---------', processDiedInfo);
| uid<sup>9+</sup> | Read only | number | No | User ID.| | uid<sup>9+</sup> | Read only | number | No | User ID.|
| processName<sup>9+</sup> | Read only | string | No | Process name.| | 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.| | 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( ...@@ -119,7 +119,7 @@ helper.on(
off(type: 'dataChange', uri: string, callback?: AsyncCallback\<void>): void 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 **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
...@@ -647,7 +647,7 @@ Deletes one or more data records from the database. This API uses an asynchronou ...@@ -647,7 +647,7 @@ Deletes one or more data records from the database. This API uses an asynchronou
```js ```js
import featureAbility from '@ohos.ability.featureAbility' 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( var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility"
); );
...@@ -662,7 +662,7 @@ DAHelper.delete( ...@@ -662,7 +662,7 @@ DAHelper.delete(
## DataAbilityHelper.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. 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 ...@@ -685,7 +685,7 @@ Deletes one or more data records from the database. This API uses a promise to r
```js ```js
import featureAbility from '@ohos.ability.featureAbility' 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( var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility"
); );
...@@ -719,7 +719,7 @@ Updates data records in the database. This API uses an asynchronous callback to ...@@ -719,7 +719,7 @@ Updates data records in the database. This API uses an asynchronous callback to
```js ```js
import featureAbility from '@ohos.ability.featureAbility' 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( var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility"
); );
...@@ -741,7 +741,7 @@ DAHelper.update( ...@@ -741,7 +741,7 @@ DAHelper.update(
## DataAbilityHelper.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. 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 ...@@ -765,7 +765,7 @@ Updates data records in the database. This API uses a promise to return the resu
```js ```js
import featureAbility from '@ohos.ability.featureAbility' 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( var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility"
); );
...@@ -806,7 +806,7 @@ Queries data in the database. This API uses an asynchronous callback to return t ...@@ -806,7 +806,7 @@ Queries data in the database. This API uses an asynchronous callback to return t
```js ```js
import featureAbility from '@ohos.ability.featureAbility' 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( var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility"
); );
...@@ -825,7 +825,7 @@ DAHelper.query( ...@@ -825,7 +825,7 @@ DAHelper.query(
## DataAbilityHelper.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. 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. ...@@ -849,7 +849,7 @@ Queries data in the database. This API uses a promise to return the result.
```js ```js
import featureAbility from '@ohos.ability.featureAbility' 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( var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility"
); );
...@@ -876,7 +876,7 @@ Calls the extended API of the Data ability. This API uses a promise to return th ...@@ -876,7 +876,7 @@ Calls the extended API of the Data ability. This API uses a promise to return th
| Name | Type | Mandatory| Description | | 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. | | method | string | Yes | Name of the API to call. |
| arg | string | Yes |Parameter to pass. | | arg | string | Yes |Parameter to pass. |
| extras | [PacMap](#pacmap) | Yes | Key-value pair parameter. | | 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 ...@@ -912,7 +912,7 @@ Calls the extended API of the Data ability. This API uses an asynchronous callba
| Name | Type | Mandatory| Description | | 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. | | method | string | Yes | Name of the API to call. |
| arg | string | Yes |Parameter to pass. | | arg | string | Yes |Parameter to pass. |
| extras | [PacMap](#pacmap) | Yes | Key-value pair parameter. | | extras | [PacMap](#pacmap) | Yes | Key-value pair parameter. |
...@@ -932,8 +932,107 @@ dataAbilityHelper.call("dataability:///com.example.jsapidemo.UserDataAbility", " ...@@ -932,8 +932,107 @@ dataAbilityHelper.call("dataability:///com.example.jsapidemo.UserDataAbility", "
console.info('Operation succeeded: ' + data); 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 ## PacMap
[key: string]: number | string | boolean | Array\<string | number | boolean> | null;
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| ------ | ------ | ------ | ------ | | ------ | ------ | ------ | ------ |
| [key: string] | number \| string \| boolean \| Array\<string \| number \| boolean\> \| null | Yes| Data stored in key-value pairs.| | [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 ...@@ -35,15 +35,15 @@ Called to notify the widget provider that a **Form** instance (widget) has been
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | 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.| | 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** **Return value**
| Type | Description | | Type | Description |
| ------------------------------------------------------------ | ----------------------------------------------------------- | | ------------------------------------------------------------ | ----------------------------------------------------------- |
| [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | A **formBindingData.FormBindingData** object containing the data to be displayed on the widget.| | [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | A **formBindingData.FormBindingData** object containing the data to be displayed on the widget.|
**Example** **Example**
...@@ -72,9 +72,9 @@ Called to notify the widget provider that a temporary widget has been converted ...@@ -72,9 +72,9 @@ Called to notify the widget provider that a temporary widget has been converted
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------ | | ------ | ------ | ---- | ------------------------ |
| formId | string | Yes | ID of the widget that requests to be converted to a normal one.| | formId | string | Yes | ID of the widget that requests to be converted to a normal one.|
**Example** **Example**
...@@ -96,9 +96,9 @@ Called to notify the widget provider that a widget has been updated. After obtai ...@@ -96,9 +96,9 @@ Called to notify the widget provider that a widget has been updated. After obtai
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------ | | ------ | ------ | ---- | ------------------ |
| formId | string | Yes | ID of the widget that requests to be updated.| | formId | string | Yes | ID of the widget that requests to be updated.|
**Example** **Example**
...@@ -127,9 +127,9 @@ Called to notify the widget provider of the change of visibility. ...@@ -127,9 +127,9 @@ Called to notify the widget provider of the change of visibility.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | ------------------------- | ---- | ---------------------------- | | --------- | ------------------------- | ---- | ---------------------------- |
| newStatus | { [key: string]: number } | Yes | ID and visibility status of the widget to be changed.| | newStatus | { [key: string]: number } | Yes | ID and visibility status of the widget to be changed.|
**Example** **Example**
...@@ -162,10 +162,10 @@ Called to instruct the widget provider to receive and process the widget event. ...@@ -162,10 +162,10 @@ Called to instruct the widget provider to receive and process the widget event.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------ | ---- | ---------------------- | | ------- | ------ | ---- | ---------------------- |
| formId | string | Yes | ID of the widget that requests the event.| | formId | string | Yes | ID of the widget that requests the event.|
| message | string | Yes | Event message. | | message | string | Yes | Event message. |
**Example** **Example**
...@@ -187,9 +187,9 @@ Called to notify the widget provider that a **Form** instance (widget) has been ...@@ -187,9 +187,9 @@ Called to notify the widget provider that a **Form** instance (widget) has been
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------ | | ------ | ------ | ---- | ------------------ |
| formId | string | Yes | ID of the widget to be destroyed.| | formId | string | Yes | ID of the widget to be destroyed.|
**Example** **Example**
...@@ -211,9 +211,9 @@ Called when the configuration of the environment where the ability is running is ...@@ -211,9 +211,9 @@ Called when the configuration of the environment where the ability is running is
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| config | [Configuration](js-apis-configuration.md) | Yes| New configuration.| | config | [Configuration](js-apis-configuration.md) | Yes| New configuration.|
**Example** **Example**
...@@ -235,9 +235,9 @@ Called when the widget provider receives the status query result of a widget. By ...@@ -235,9 +235,9 @@ Called when the widget provider receives the status query result of a widget. By
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | 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.| | 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** **Example**
...@@ -250,3 +250,40 @@ Called when the widget provider receives the status query result of a widget. By ...@@ -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 @@ ...@@ -2,13 +2,32 @@
The **FormExtensionContext** module, inherited from **ExtensionContext**, provides context for Form Extension abilities. 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** > **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 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. > 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 ## FormExtensionContext.startAbility
startAbility(want: Want, callback: AsyncCallback&lt;void&gt;): void 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. ...@@ -64,7 +83,7 @@ Starts an ability. This API uses a promise to return the result.
| Type | Description | | Type | Description |
| ------------ | ---------------------------------- | | ------------ | ---------------------------------- |
| Promise\<void> | Promise used to return the result.| | Promise&lt;void&lt; | Promise used to return the result.|
**Example** **Example**
......
...@@ -189,6 +189,7 @@ Obtains the application's widget information that meets a filter criterion on th ...@@ -189,6 +189,7 @@ Obtains the application's widget information that meets a filter criterion on th
**Example** **Example**
```js ```js
import formInfo from '@ohos.application.formInfo';
const filter : formInfo.FormInfoFilter = { const filter : formInfo.FormInfoFilter = {
moduleName : "entry" moduleName : "entry"
}; };
...@@ -224,6 +225,7 @@ Obtains the application's widget information on the device. This API uses a prom ...@@ -224,6 +225,7 @@ Obtains the application's widget information on the device. This API uses a prom
**Example** **Example**
```js ```js
import formInfo from '@ohos.application.formInfo';
const filter : formInfo.FormInfoFilter = { const filter : formInfo.FormInfoFilter = {
moduleName : "entry" moduleName : "entry"
}; };
...@@ -236,13 +238,13 @@ formProvider.getFormsInfo(filter).then((data) => { ...@@ -236,13 +238,13 @@ formProvider.getFormsInfo(filter).then((data) => {
## requestPublishForm<sup>9+</sup> ## 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. 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** **Parameters**
...@@ -276,13 +278,13 @@ SystemCapability.Ability.Form ...@@ -276,13 +278,13 @@ SystemCapability.Ability.Form
## requestPublishForm<sup>9+</sup> ## 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. 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** **Parameters**
...@@ -317,9 +319,9 @@ requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData ...@@ -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. 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** **Parameters**
...@@ -360,6 +362,8 @@ Checks whether a widget can be published to the widget host. This API uses an as ...@@ -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 capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
...@@ -402,6 +406,8 @@ Checks whether a widget can be published to the widget host. This API uses a pro ...@@ -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 capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Return value** **Return value**
| Type | Description | | Type | Description |
......
...@@ -362,6 +362,88 @@ Obtains the snapshot of a given mission. This API uses a promise to return the r ...@@ -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 ## missionManager.lockMission
......
...@@ -23,9 +23,9 @@ None. ...@@ -23,9 +23,9 @@ None.
**System API**: This is a system API and cannot be called by third-party applications. **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 ## ServiceExtensionAbility.onCreate
...@@ -40,9 +40,9 @@ Called when a Service Extension ability is created to initialize the service log ...@@ -40,9 +40,9 @@ Called when a Service Extension ability is created to initialize the service log
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | 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.| | want | [Want](js-apis-application-Want.md) | Yes| Information related to this Service Extension ability, including the ability name and bundle name.|
**Example** **Example**
...@@ -88,10 +88,10 @@ Called after **onCreate** is invoked when a Service Extension ability is started ...@@ -88,10 +88,10 @@ Called after **onCreate** is invoked when a Service Extension ability is started
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | 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.| | 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.| | startId | number | Yes| Number of ability start times. The initial value is **1**, and the value is automatically incremented for each ability started.|
**Example** **Example**
...@@ -116,15 +116,15 @@ Called after **onCreate** is invoked when a Service Extension ability is started ...@@ -116,15 +116,15 @@ Called after **onCreate** is invoked when a Service Extension ability is started
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | 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.| | want | [Want](js-apis-application-Want.md)| Yes| Information related to this Service Extension ability, including the ability name and bundle name.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| rpc.RemoteObject | A **RemoteObject** object used for communication with the client.| | rpc.RemoteObject | A **RemoteObject** object used for communication with the client.|
**Example** **Example**
...@@ -158,9 +158,9 @@ Called when this Service Extension ability is disconnected. ...@@ -158,9 +158,9 @@ Called when this Service Extension ability is disconnected.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | 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.| | want |[Want](js-apis-application-Want.md)| Yes| Information related to this Service Extension ability, including the ability name and bundle name.|
**Example** **Example**
...@@ -184,16 +184,16 @@ Called when this Service Extension ability is reconnected. ...@@ -184,16 +184,16 @@ Called when this Service Extension ability is reconnected.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | 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.| | want |[Want](js-apis-application-Want.md)| Yes| Information related to this Service Extension ability, including the ability name and bundle name.|
**Example** **Example**
```js ```js
class ServiceExt extends ServiceExtension { class ServiceExt extends ServiceExtension {
onDisconnect(want) { onReconnect(want) {
console.log('onDisconnect, want:' + want.abilityName); console.log('onReconnect, want:' + want.abilityName);
} }
} }
``` ```
...@@ -202,7 +202,7 @@ Called when this Service Extension ability is reconnected. ...@@ -202,7 +202,7 @@ Called when this Service Extension ability is reconnected.
onConfigurationUpdated(config: Configuration): void; 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 **System capability**: SystemCapability.Ability.AbilityRuntime.Core
...@@ -210,9 +210,9 @@ Called when the configuration of this Service Extension ability is updated. ...@@ -210,9 +210,9 @@ Called when the configuration of this Service Extension ability is updated.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| config | [Configuration](js-apis-configuration.md) | Yes| New configuration.| | config | [Configuration](js-apis-configuration.md) | Yes| New configuration.|
**Example** **Example**
...@@ -236,9 +236,9 @@ Dumps the client information. ...@@ -236,9 +236,9 @@ Dumps the client information.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| params | Array\<string> | Yes| Parameters in the form of a command.| | params | Array\<string> | Yes| Parameters in the form of a command.|
**Example** **Example**
......
...@@ -26,7 +26,7 @@ Before using the **ServiceExtensionContext** module, you must define a child cla ...@@ -26,7 +26,7 @@ Before using the **ServiceExtensionContext** module, you must define a child cla
startAbility(want: Want, callback: AsyncCallback&lt;void&gt;): void; 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 **System capability**: SystemCapability.Ability.AbilityRuntime.Core
...@@ -36,8 +36,8 @@ Starts an ability. This API uses a callback to return the result. ...@@ -36,8 +36,8 @@ Starts an ability. This API uses a callback to return the result.
| Name| Type| Mandatory| Description| | 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.|
| 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** **Example**
...@@ -64,14 +64,14 @@ Starts an ability. This API uses a promise to return the result. ...@@ -64,14 +64,14 @@ Starts an ability. This API uses a promise to return the result.
| Name| Type| Mandatory| Description| | 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.| | options | [StartOptions](js-apis-application-StartOptions.md) | Yes| Parameters used for starting the ability.|
**Return value** **Return value**
| Type| Description| | 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** **Example**
...@@ -92,7 +92,7 @@ Starts an ability. This API uses a promise to return the result. ...@@ -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 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 **System capability**: SystemCapability.Ability.AbilityRuntime.Core
...@@ -102,7 +102,7 @@ Starts an ability. This API uses a callback to return the result. ...@@ -102,7 +102,7 @@ Starts an ability. This API uses a callback to return the result.
| Name| Type| Mandatory| Description| | 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.| | 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.| | 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 ...@@ -136,8 +136,8 @@ Starts an ability with the account ID specified. This API uses an asynchronous c
| Name| Type| Mandatory| Description| | 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.|
| accountId | number | Yes| ID of the account.| | 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.| | callback | AsyncCallback\<void\> | Yes| Callback used to return the result.|
**Example** **Example**
...@@ -169,8 +169,8 @@ Starts an ability with the account ID specified. This API uses an asynchronous c ...@@ -169,8 +169,8 @@ Starts an ability with the account ID specified. This API uses an asynchronous c
| Name| Type| Mandatory| Description| | 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.|
| accountId | number | Yes| ID of the account.| | 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.| | options | [StartOptions](js-apis-application-StartOptions.md) | No| Parameters used for starting the ability.|
| callback | AsyncCallback\<void\> | Yes| Callback used to return the result.| | 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 ...@@ -206,10 +206,16 @@ Starts an ability with the account ID specified. This API uses a promise to retu
| Name| Type| Mandatory| Description| | 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.|
| accountId | number | Yes| ID of the account.| | 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.| | 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** **Example**
```js ```js
...@@ -245,7 +251,7 @@ Starts a new Service Extension ability. This API uses an asynchronous callback t ...@@ -245,7 +251,7 @@ Starts a new Service Extension ability. This API uses an asynchronous callback t
| Name| Type| Mandatory| Description| | 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.| | callback | AsyncCallback\<void\> | Yes| Callback used to return the result.|
**Example** **Example**
...@@ -275,7 +281,13 @@ Starts a new Service Extension ability. This API uses a promise to return the re ...@@ -275,7 +281,13 @@ Starts a new Service Extension ability. This API uses a promise to return the re
| Name| Type| Mandatory| Description| | 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** **Example**
...@@ -310,8 +322,8 @@ Starts a new Service Extension ability with the account ID specified. This API u ...@@ -310,8 +322,8 @@ Starts a new Service Extension ability with the account ID specified. This API u
| Name| Type| Mandatory| Description| | 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.|
| accountId | number | Yes| ID of the account.| | 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.| | callback | AsyncCallback\<void\> | Yes| Callback used to return the result.|
**Example** **Example**
...@@ -344,8 +356,14 @@ Starts a new Service Extension ability with the account ID specified. This API u ...@@ -344,8 +356,14 @@ Starts a new Service Extension ability with the account ID specified. This API u
| Name| Type| Mandatory| Description| | 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.|
| accountId | number | Yes| ID of the account.| | 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** **Example**
...@@ -369,7 +387,7 @@ Starts a new Service Extension ability with the account ID specified. This API u ...@@ -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; 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 **System capability**: SystemCapability.Ability.AbilityRuntime.Core
...@@ -379,7 +397,7 @@ Stops Service Extension abilities in the same application. This API uses an asyn ...@@ -379,7 +397,7 @@ Stops Service Extension abilities in the same application. This API uses an asyn
| Name| Type| Mandatory| Description| | 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.| | callback | AsyncCallback\<void\> | Yes| Callback used to return the result.|
**Example** **Example**
...@@ -399,7 +417,7 @@ Stops Service Extension abilities in the same application. This API uses an asyn ...@@ -399,7 +417,7 @@ Stops Service Extension abilities in the same application. This API uses an asyn
stopServiceExtensionAbility(want: Want): Promise\<void>; 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 **System capability**: SystemCapability.Ability.AbilityRuntime.Core
...@@ -409,7 +427,13 @@ Stops Service Extension abilities in the same application. This API uses a promi ...@@ -409,7 +427,13 @@ Stops Service Extension abilities in the same application. This API uses a promi
| Name| Type| Mandatory| Description| | 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** **Example**
...@@ -432,7 +456,7 @@ Stops Service Extension abilities in the same application. This API uses a promi ...@@ -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; 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 **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 ...@@ -444,8 +468,8 @@ Stops Service Extension abilities in the same application with the account ID sp
| Name| Type| Mandatory| Description| | 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.|
| accountId | number | Yes| ID of the account.| | 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.| | callback | AsyncCallback\<void\> | Yes| Callback used to return the result.|
**Example** **Example**
...@@ -466,7 +490,7 @@ Stops Service Extension abilities in the same application with the account ID sp ...@@ -466,7 +490,7 @@ Stops Service Extension abilities in the same application with the account ID sp
stopServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\<void>; 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 **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 ...@@ -478,8 +502,14 @@ Stops Service Extension abilities in the same application with the account ID sp
| Name| Type| Mandatory| Description| | 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.|
| accountId | number | Yes| ID of the account.| | 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** **Example**
...@@ -503,7 +533,7 @@ Stops Service Extension abilities in the same application with the account ID sp ...@@ -503,7 +533,7 @@ Stops Service Extension abilities in the same application with the account ID sp
terminateSelf(callback: AsyncCallback&lt;void&gt;): void; 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 **System capability**: SystemCapability.Ability.AbilityRuntime.Core
...@@ -513,7 +543,7 @@ Terminates this ability. This API uses a callback to return the result. ...@@ -513,7 +543,7 @@ Terminates this ability. This API uses a callback to return the result.
| Name| Type| Mandatory| Description| | 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** **Example**
...@@ -537,7 +567,7 @@ Terminates this ability. This API uses a promise to return the result. ...@@ -537,7 +567,7 @@ Terminates this ability. This API uses a promise to return the result.
| Type| Description| | 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** **Example**
...@@ -563,7 +593,7 @@ Connects this ability to a Service ability. ...@@ -563,7 +593,7 @@ Connects this ability to a Service ability.
| Name| Type| Mandatory| Description| | 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.| | 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** **Return value**
...@@ -601,8 +631,8 @@ Uses the **AbilityInfo.AbilityType.SERVICE** template and account ID to connect ...@@ -601,8 +631,8 @@ Uses the **AbilityInfo.AbilityType.SERVICE** template and account ID to connect
| Name| Type| Mandatory| Description| | 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.|
| accountId | number | Yes| ID of the account.| | accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
| options | ConnectOptions | No| Remote object instance.| | options | ConnectOptions | No| Remote object instance.|
**Return value** **Return value**
...@@ -633,7 +663,7 @@ Uses the **AbilityInfo.AbilityType.SERVICE** template and account ID to connect ...@@ -633,7 +663,7 @@ Uses the **AbilityInfo.AbilityType.SERVICE** template and account ID to connect
disconnectAbility(connection: number, callback:AsyncCallback&lt;void&gt;): void; 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 **System capability**: SystemCapability.Ability.AbilityRuntime.Core
...@@ -644,7 +674,7 @@ Disconnects this ability from the Service ability. This API uses a callback to r ...@@ -644,7 +674,7 @@ Disconnects this ability from the Service ability. This API uses a callback to r
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| connection | number | Yes| Number returned after **connectAbility** is called.| | 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** **Example**
...@@ -676,7 +706,7 @@ Disconnects this ability from the Service ability. This API uses a promise to re ...@@ -676,7 +706,7 @@ Disconnects this ability from the Service ability. This API uses a promise to re
| Type| Description| | 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** **Example**
...@@ -689,3 +719,41 @@ Disconnects this ability from the Service ability. This API uses a promise to re ...@@ -689,3 +719,41 @@ Disconnects this ability from the Service ability. This API uses a promise to re
console.log('failed:' + JSON.stringify(error)); 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.
先完成此消息的编辑!
想要评论请 注册