未验证 提交 1bf4fef6 编写于 作者: O openharmony_ci 提交者: Gitee

!10051 翻译完成:8654+8922+9252+9477+9517+8886+9961+10004 Fix document error of ability

Merge pull request !10051 from wusongqing/TR8654V2
......@@ -6,8 +6,8 @@ This module provides APIs for accessing ability-specific resources. You can use
> **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.
> - 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
......
......@@ -4,12 +4,12 @@ The **wantConstant** module provides the actions, entities, and flags used in **
> **NOTE**
>
> The initial APIs of this module are supported since API 6. 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 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```
import wantConstant from '@ohos.ability.wantConstant'
```js
import wantConstant from '@ohos.ability.wantConstant';
```
## wantConstant.Action
......@@ -46,8 +46,13 @@ Enumerates the action constants of the **Want** object.
| ACTION_FILE_SELECT<sup>7+</sup> | ohos.action.fileSelect | Action of selecting a file. |
| PARAMS_STREAM<sup>7+</sup> | ability.params.stream | URI of the data stream associated with the target when the data is sent. |
| ACTION_APP_ACCOUNT_OAUTH <sup>8+</sup> | ohos.account.appAccount.action.oauth | Action of providing the OAuth service. |
| ACTION_MARKER_DOWNLOAD <sup>9+</sup> | ohos.want.action.marketDownload | Action of downloading an application from the application market.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| ACTION_MARKET_DOWNLOAD <sup>9+</sup> | ohos.want.action.marketDownload | Action of downloading an application from the application market.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| ACTION_MARKET_CROWDTEST <sup>9+</sup> | ohos.want.action.marketCrowdTest | Action of crowdtesting an application from the application market.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| DLP_PARAMS_SANDBOX<sup>9+</sup> |ohos.dlp.params.sandbox | Action of obtaining the sandbox flag.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| DLP_PARAMS_BUNDLE_NAME<sup>9+</sup> |ohos.dlp.params.bundleName |Action of obtaining the DLP bundle name.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| DLP_PARAMS_MODULE_NAME<sup>9+</sup> |ohos.dlp.params.moduleName |Action of obtaining the DLP module name.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| DLP_PARAMS_ABILITY_NAME<sup>9+</sup> |ohos.dlp.params.abilityName |Action of obtaining the DLP ability name.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| DLP_PARAMS_INDEX<sup>9+</sup> |ohos.dlp.params.index |Action of obtaining the DLP index.<br>**System API**: This is a system API and cannot be called by third-party applications. |
## wantConstant.Entity
......
......@@ -4,7 +4,7 @@ The **Ability** module manages the ability lifecycle and context, such as creati
This module provides the following common ability-related functions:
- [Caller](#caller): implements sending of sequenceable data to the target ability when an ability (caller) invokes the target ability (callee).
- [Caller](#caller): implements sending of sequenceable data to the target ability when an ability (caller ability) invokes the target ability (callee ability).
- [Callee](#callee): implements callbacks for registration and deregistration of caller notifications.
> **NOTE**
......@@ -39,10 +39,10 @@ Called to initialize the service logic when an ability is created.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information related to this ability, including the ability name and bundle name.|
| param | AbilityConstant.LaunchParam | Yes| Parameters for starting the ability, and the reason for the last abnormal exit.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information related to this ability, including the ability name and bundle name.|
| param | AbilityConstant.LaunchParam | Yes| Parameters for starting the ability, and the reason for the last abnormal exit.|
**Example**
......@@ -65,9 +65,9 @@ Called when a **WindowStage** is created for this ability.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| windowStage | window.WindowStage | Yes| **WindowStage** information.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| windowStage | window.WindowStage | Yes| **WindowStage** information.|
**Example**
......@@ -109,9 +109,9 @@ Called when the **WindowStage** is restored during the migration of this ability
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| windowStage | window.WindowStage | Yes| **WindowStage** information.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| windowStage | window.WindowStage | Yes| **WindowStage** information.|
**Example**
......@@ -191,15 +191,15 @@ Called to save data during the ability migration preparation process.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| wantParam | {[key:&nbsp;string]:&nbsp;any} | Yes| **want** parameter.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| wantParam | {[key:&nbsp;string]:&nbsp;any} | Yes| **want** parameter.|
**Return value**
| Type| Description|
| -------- | -------- |
| AbilityConstant.OnContinueResult | Continuation result.|
| Type| Description|
| -------- | -------- |
| AbilityConstant.OnContinueResult | Continuation result.|
**Example**
......@@ -225,20 +225,17 @@ Called when the ability startup mode is set to singleton.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Want parameters, such as the ability name and bundle name.|
| launchParams | AbilityConstant.LaunchParam | Yes| Reason for the ability startup and the last abnormal exit.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Want parameters, such as the ability name and bundle name.|
| launchParams | AbilityConstant.LaunchParam | Yes| Reason for the ability startup and the last abnormal exit.|
**Example**
```js
class myAbility extends Ability {
onNewWant(want, launchParams) {
onNewWant(want) {
console.log('onNewWant, want:' + want.abilityName);
if (launchParams.launchReason === AbilityConstant.LaunchReason.CONTINUATION) {
console.log('onNewWant, launchReason is continuation');
}
}
}
```
......@@ -254,9 +251,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**
......@@ -278,9 +275,9 @@ Dumps 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**
......@@ -293,11 +290,35 @@ Dumps client information.
}
```
## Ability.onMemoryLevel
onMemoryLevel(level: AbilityConstant.MemoryLevel): void;
Called when the system has decided to adjust the memory level. For example, this API can be used when there is not enough memory to run as many background processes as possible.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| level | [AbilityConstant.MemoryLevel](js-apis-application-abilityConstant.md#abilityconstantmemorylevel) | Yes| Memory level that indicates the memory usage status. When the specified memory level is reached, a callback will be invoked and the system will start adjustment.|
**Example**
```js
class myAbility extends Ability {
onMemoryLevel(level) {
console.log('onMemoryLevel, level:' + JSON.stringify(level));
}
}
```
## Caller
Implements sending of sequenceable data to the target ability when an ability (caller) invokes the target ability (callee).
Implements sending of sequenceable data to the target ability when an ability (caller ability) invokes the target ability (callee ability).
## Caller.call
......@@ -310,16 +331,16 @@ Sends sequenceable data to the target ability.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| method | string | Yes| Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data.|
| data | rpc.Sequenceable | Yes| Sequenceable data. You need to customize the data.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| method | string | Yes| Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data.|
| data | rpc.Sequenceable | Yes| Sequenceable data. You need to customize the data.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return a response.|
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return a response.|
**Example**
......@@ -383,16 +404,16 @@ Sends sequenceable data to the target ability and obtains the sequenceable data
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| method | string | Yes| Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data.|
| data | rpc.Sequenceable | Yes| Sequenceable data. You need to customize the data.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| method | string | Yes| Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data.|
| data | rpc.Sequenceable | Yes| Sequenceable data. You need to customize the data.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;rpc.MessageParcel&gt; | Promise used to return the sequenceable data from the target ability.|
| Type| Description|
| -------- | -------- |
| Promise&lt;rpc.MessageParcel&gt; | Promise used to return the sequenceable data from the target ability.|
**Example**
......@@ -492,9 +513,9 @@ Registers a callback that is invoked when the stub on the target ability is disc
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | OnReleaseCallBack | Yes| Callback used for the **onRelease** API.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | OnReleaseCallBack | Yes| Callback used for the **onRelease** API.|
**Example**
......@@ -540,12 +561,13 @@ Registers a caller notification callback, which is invoked when the target abili
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| method | string | Yes| Notification message string negotiated between the two abilities.|
| callback | CalleeCallBack | Yes| JS notification synchronization callback of the **rpc.MessageParcel** type. The callback must return at least one empty **rpc.Sequenceable** object. Otherwise, the function execution fails.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| method | string | Yes| Notification message string negotiated between the two abilities.|
| callback | CalleeCallBack | Yes| JS notification synchronization callback of the **rpc.MessageParcel** type. The callback must return at least one empty **rpc.Sequenceable** object. Otherwise, the function execution fails.|
**Example**
```js
import Ability from '@ohos.application.Ability';
class MyMessageAble{
......@@ -595,9 +617,9 @@ Deregisters a caller notification callback, which is invoked when the target abi
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| method | string | Yes| Registered notification message string.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| method | string | Yes| Registered notification message string.|
**Example**
......@@ -622,8 +644,7 @@ Deregisters a caller notification callback, which is invoked when the target abi
| -------- | -------- | -------- | -------- | -------- |
| (msg: string) | function | Yes| No| Prototype of the listener function registered by the caller.|
## CalleeCallBack
## CalleeCallBack
(indata: rpc.MessageParcel): rpc.Sequenceable;
......
......@@ -65,7 +65,7 @@ Enumerates ability continuation results.
## AbilityConstant.WindowMode
Enumerates the window modes when an ability is started.
Enumerates the window modes in which an ability can be displayed at startup.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -76,3 +76,15 @@ Enumerates the window modes when an ability is started.
| WINDOW_MODE_SPLIT_PRIMARY | 100 | The ability is displayed in the primary window in split-screen mode. |
| WINDOW_MODE_SPLIT_SECONDARY | 101 | The ability is displayed in the secondary window in split-screen mode. |
| WINDOW_MODE_FLOATING | 102 | The ability is displayed in a floating window.|
## AbilityConstant.MemoryLevel
Enumerates the memory levels.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value| Description |
| --- | --- | --- |
| MEMORY_LEVEL_MODERATE | 0 | Moderate memory usage. |
| MEMORY_LEVEL_LOW | 1 | Low memory usage. |
| MEMORY_LEVEL_CRITICAL | 2 | High memory usage. |
......@@ -875,3 +875,265 @@ abilityDelegator.finishTest(msg, 0).then(() => {
console.info("finishTest promise");
});
```
### addAbilityStageMonitor<sup>9+</sup>
addAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback\<void>): void;
Adds an **AbilityStageMonitor** instance to monitor the lifecycle state changes of an ability stage. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | -------- | ------------------------------------------------------------ |
| monitor | [AbilityStageMonitor](#abilitystagemonitor) | Yes | [AbilityStageMonitor](#abilitystagemonitor) instance.|
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. |
**Example**
```js
var abilityDelegator;
var monitor = {
moduleName: "moduleName",
srcEntrance: "srcEntrance",
}
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.addAbilityStageMonitor(monitor, (err : any) => {
console.info("addAbilityStageMonitor callback");
});
```
### addAbilityStageMonitor<sup>9+</sup>
addAbilityStageMonitor(monitor: AbilityStageMonitor): Promise\<void>;
Adds an **AbilityStageMonitor** instance to monitor the lifecycle state changes of an ability stage. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| monitor | [AbilityStageMonitor](#abilitystagemonitor) | Yes | [AbilityStageMonitor](#abilitystagemonitor) instance.|
**Return value**
| Type | Description |
| -------------- | ------------------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```js
var abilityDelegator;
var monitor = {
moduleName: "moduleName",
srcEntrance: "srcEntrance",
}
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.addAbilityStageMonitor(monitor).then(() => {
console.info("addAbilityStageMonitor promise");
});
```
### removeAbilityStageMonitor<sup>9+</sup>
removeAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback\<void>): void;
Removes an **AbilityStageMonitor** instance from the application memory. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | -------- | ------------------------------------------------------------ |
| monitor | [AbilityStageMonitor](#abilitystagemonitor) | Yes | [AbilityStageMonitor](#abilitystagemonitor) instance.|
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. |
**Example**
```js
var abilityDelegator;
var monitor = {
moduleName: "moduleName",
srcEntrance: "srcEntrance",
}
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.removeAbilityStageMonitor(monitor, (err : any) => {
console.info("removeAbilityStageMonitor callback");
});
```
### removeAbilityStageMonitor<sup>9+</sup>
removeAbilityStageMonitor(monitor: AbilityStageMonitor): Promise\<void>;
Removes an **AbilityStageMonitor** object from the application memory. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| monitor | [AbilityStageMonitor](#abilitystagemonitor) | Yes | [AbilityStageMonitor](#abilitystagemonitor) instance.|
**Return value**
| Type | Description |
| -------------- | ------------------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```js
var abilityDelegator;
var monitor = {
moduleName: "moduleName",
srcEntrance: "srcEntrance",
}
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.removeAbilityStageMonitor(monitor).then(() => {
console.info("removeAbilityStageMonitor promise");
});
```
### waitAbilityStageMonitor<sup>9+</sup>
waitAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback\<AbilityStage>): void;
Waits for an **AbilityStage** instance that matches the conditions set in an **AbilityStageMonitor** instance and returns the **AbilityStage** instance. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | -------- | ------------------------------------------------------------ |
| monitor | [AbilityStageMonitor](#abilitystagemonitor) | Yes | [AbilityStageMonitor](#abilitystagemonitor) instance.|
| callback | AsyncCallback\<AbilityStage> | Yes | Callback used to return the result. If the operation is successful, an **AbilityStage** instance is returned. Otherwise, no value is returned. |
**Example**
```js
var abilityDelegator;
function onAbilityCreateCallback(data) {
console.info("onAbilityCreateCallback");
}
var monitor = {
moduleName: "moduleName",
srcEntrance: "srcEntrance",
}
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.waitAbilityStageMonitor(monitor, (err : any, data : any) => {
console.info("waitAbilityStageMonitor callback");
});
```
### waitAbilityStageMonitor<sup>9+</sup>
waitAbilityStageMonitor(monitor: AbilityStageMonitor, timeout?: number): Promise\<AbilityStage>;
Waits for an **AbilityStage** instance that matches the conditions set in an **AbilityStageMonitor** instance and returns the **AbilityStage** instance. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| monitor | [AbilityStageMonitor](#abilitystagemonitor) | Yes | [AbilityStageMonitor](#abilitystagemonitor) instance.|
| timeout | number | No | Maximum waiting time, in milliseconds.|
**Return value**
| Type | Description |
| -------------- | ------------------- |
| Promise\<AbilityStage> | Promise used to return the result. If the operation is successful, an **AbilityStage** instance is returned. Otherwise, no value is returned.|
**Example**
```js
var abilityDelegator;
function onAbilityCreateCallback(data) {
console.info("onAbilityCreateCallback");
}
var monitor = {
moduleName: "moduleName",
srcEntrance: "srcEntrance",
}
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.waitAbilityStageMonitor(monitor).then((data : any) => {
console.info("waitAbilityStageMonitor promise");
});
```
### waitAbilityStageMonitor<sup>9+</sup>
waitAbilityStageMonitor(monitor: AbilityStageMonitor, timeout: number, callback: AsyncCallback\<AbilityStage>): void;
Waits a period of time for an **AbilityStage** instance that matches the conditions set in an **AbilityStageMonitor** instance and returns the **AbilityStage** instance. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| monitor | [AbilityStageMonitor](#abilitystagemonitor) | Yes | [AbilityStageMonitor](#abilitystagemonitor) instance.|
| timeout | number | No | Maximum waiting time, in milliseconds.|
| callback | AsyncCallback\<AbilityStage> | Yes | Callback used to return the result. If the operation is successful, an **AbilityStage** instance is returned. Otherwise, no value is returned. |
**Example**
```js
var abilityDelegator;
var timeout = 100;
function onAbilityCreateCallback(data) {
console.info("onAbilityCreateCallback");
}
var monitor = {
moduleName: "moduleName",
srcEntrance: "srcEntrance",
}
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.waitAbilityStageMonitor(monitor, timeout, (err : any, data : any) => {
console.info("waitAbilityStageMonitor callback");
});
```
## AbilityStageMonitor
Provides conditions for matching **AbilityStage** instances. The most recently matched **AbilityStage** instance is saved in an **AbilityStageMonitor** instance.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Type | Readable| Writable| Description |
| ------------------------------------------------------------ | -------- | ---- | ---- | ------------------------------------------------------------ |
| moduleName<sup>9+</sup> | string | Yes | Yes | Module name of the **AbilityStage** instance.|
| srcEntrance<sup>9+</sup> | string | Yes | Yes | Source path of the **AbilityStage** instance.|
......@@ -11,7 +11,7 @@ The **AbilityDelegatorArgs** module provides a global register to store the regi
The ability delegator arguments are obtained by calling **getArguments** in **AbilityDelegatorRegistry**.
```js
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
var args = AbilityDelegatorRegistry.getArguments();
```
......
......@@ -89,6 +89,31 @@ Called when the global configuration is updated.
}
}
```
## AbilityStage.onMemoryLevel
onMemoryLevel(level: AbilityConstant.MemoryLevel): void;
Called when the system has decided to adjust the memory level. For example, this API can be used when there is not enough memory to run as many background processes as possible.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| level | [AbilityConstant.MemoryLevel](js-apis-application-abilityConstant.md#abilityconstantmemorylevel) | Yes| Memory level that indicates the memory usage status. When the specified memory level is reached, a callback will be invoked and the system will start adjustment.|
**Example**
```js
class MyAbilityStage extends AbilityStage {
onMemoryLevel(level) {
console.log('onMemoryLevel, level:' + JSON.stringify(level));
}
}
```
## AbilityStage.context
context: AbilityStageContext;
......
......@@ -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**
......@@ -157,14 +157,12 @@ Obtains the memory size of this application. This API uses an asynchronous callb
```
## 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>>;
Obtains information about the running processes. This API uses a promise to return the result.
> This API is deprecated since API version 9. You are advised to use [appManager.getProcessRunningInformation<sup>9+</sup>](#appmanagergetprocessrunninginformation9) instead.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -187,14 +185,12 @@ Obtains information about the running processes. This API uses a promise to retu
## 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;
Obtains information about the running processes. This API uses an asynchronous callback to return the result.
> This API is deprecated since API version 9. You are advised to use [appManager.getProcessRunningInformation<sup>9+</sup>](#appmanagergetprocessrunninginformation9-1) instead.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -228,7 +224,7 @@ Obtains information about the running processes. This API uses a promise to retu
| Type| Description|
| -------- | -------- |
| Promise\<Array\<ProcessRunningInformation>> | Promise used to return the process information.|
| Promise\<Array\<[ProcessRunningInformation](#processrunninginformation)>> | Promise used to return the process information.|
**Example**
......@@ -254,7 +250,7 @@ Obtains information about the running processes. This API uses an asynchronous c
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback\<Array\<ProcessRunningInformation>> | No| Callback used to return the process information.|
| callback | AsyncCallback\<Array\<[ProcessRunningInformation](#processrunninginformation)>> | No| Callback used to return the process information.|
**Example**
......@@ -269,7 +265,7 @@ Obtains information about the running processes. This API uses an asynchronous c
registerApplicationStateObserver(observer: ApplicationStateObserver): number;
Registers an observer to listen for the state of all applications.
Registers an observer to listen for the state changes of all applications.
**Required permissions**: ohos.permission.RUNNING_STATE_OBSERVER
......@@ -307,9 +303,9 @@ Registers an observer to listen for the state of all applications.
## appManager.registerApplicationStateObserver<sup>9+</sup>
registerApplicationStateObserver(observer: ApplicationStateObserver, bundleNameList: Array<string>): number;
registerApplicationStateObserver(observer: ApplicationStateObserver, bundleNameList: Array\<string>): number;
Registers an observer to listen for the state of a specified application.
Registers an observer to listen for the state changes of a specified application.
**Required permissions**: ohos.permission.RUNNING_STATE_OBSERVER
......@@ -322,7 +318,7 @@ Registers an observer to listen for the state of a specified application.
| 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.|
| bundleNameList | Array<string> | No| **bundleName** array of the application. A maximum of 128 bundle names can be passed.|
**Example**
......@@ -491,10 +487,10 @@ Kills a process by bundle name and account ID. This API uses a promise to return
**Parameters**
| 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).|
| 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**
......@@ -525,11 +521,11 @@ Kills a process by bundle name and account ID. This API uses an asynchronous cal
**Parameters**
| 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.|
| 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,9 +704,14 @@ Called when the application state changes.
**Example**
```js
import ApplicationStateObserver from '@ohos.application.ApplicationStateObserver'
const foregroundApplicationInfo = ApplicationStateObserver.onForegroundApplicationChanged();
console.log('-------- foregroundApplicationInfo: ---------', foregroundApplicationInfo);
var applicationStateObserver = {
onForegroundApplicationChanged(appStateData) {
console.log('------------ onForegroundApplicationChanged -----------', appStateData);
}
}
const observerCode = app.registerApplicationStateObserver(applicationStateObserver);
console.log('-------- observerCode: ---------', observerCode);
```
## ApplicationStateObserver.onAbilityStateChanged<sup>8+</sup>
......@@ -732,9 +733,13 @@ Called when the ability state changes.
**Example**
```js
import ApplicationStateObserver from '@ohos.application.ApplicationStateObserver'
const abilityStateChangedInfo = ApplicationStateObserver.onAbilityStateChanged();
console.log('-------- abilityStateChangedInfo: ---------', abilityStateChangedInfo);
var applicationStateObserver = {
onAbilityStateChanged(abilityStateData) {
console.log('------------ onAbilityStateChanged -----------', abilityStateData);
}
}
const observerCode = app.registerApplicationStateObserver(applicationStateObserver);
console.log('-------- observerCode: ---------', observerCode);
```
## ApplicationStateObserver.onProcessCreated<sup>8+</sup>
......@@ -756,9 +761,13 @@ Called when a process is created.
**Example**
```js
import ApplicationStateObserver from '@ohos.application.ApplicationStateObserver'
const processCreatedInfo = ApplicationStateObserver.onProcessCreated();
console.log('-------- processCreatedInfo: ---------', processCreatedInfo);
var applicationStateObserver = {
onProcessCreated(processData) {
console.log('------------ onProcessCreated -----------', processData);
}
}
const observerCode = app.registerApplicationStateObserver(applicationStateObserver);
console.log('-------- observerCode: ---------', observerCode);
```
## ApplicationStateObserver.onProcessDied<sup>8+</sup>
......@@ -775,14 +784,46 @@ Called when a process is terminated.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| processData | ProcessData | No| Process information.|
| processData | [ProcessData](#processdata) | No| Process information.|
**Example**
```js
import ApplicationStateObserver from '@ohos.application.ApplicationStateObserver'
const processDiedInfo = ApplicationStateObserver.onProcessDied();
console.log('-------- processDiedInfo: ---------', processDiedInfo);
var applicationStateObserver = {
onProcessDied(processData) {
console.log('------------ onProcessDied -----------', processData);
}
}
const observerCode = app.registerApplicationStateObserver(applicationStateObserver);
console.log('-------- observerCode: ---------', observerCode);
```
## ApplicationStateObserver.onProcessStateChanged<sup>9+</sup>
onProcessStateChanged(processData: ProcessData): void;
Called when the process state changes.
**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|
| -------- | -------- | -------- | -------- |
| processData | [ProcessData](#processdata) | No| Process information.|
**Example**
```js
var applicationStateObserver = {
onProcessStateChanged(processData) {
console.log('------------ onProcessStateChanged -----------', processData);
}
}
const observerCode = app.registerApplicationStateObserver(applicationStateObserver);
console.log('-------- observerCode: ---------', observerCode);
```
## AppStateData
......@@ -815,7 +856,7 @@ console.log('-------- processDiedInfo: ---------', processDiedInfo);
## ProcessData
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API and cannot be called by third-party applications.
......@@ -824,19 +865,19 @@ console.log('-------- processDiedInfo: ---------', processDiedInfo);
| pid<sup>8+</sup> | number | Yes | No | Process ID. |
| bundleName<sup>8+</sup> | string | Yes | No | Bundle name of an application. |
| uid<sup>8+</sup> | number | Yes | No | User ID. |
| isContinuousTask<sup>9+</sup> | boolean | Yes | No | Whether the process is a continuous task. |
| isKeepAlive<sup>9+</sup> | boolean | Yes | No | Whether the process remains active. |
## ProcessRunningInfo
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
| Name | Readable/Writable| Type | Mandatory| Description |
| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
| pid<sup>9+</sup> | Read only | number | No | Process ID. |
| 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.|
| pid<sup>8+</sup> | Read only | number | No | Process ID. |
| uid<sup>8+</sup> | Read only | number | No | User ID.|
| processName<sup>8+</sup> | Read only | string | No | Process name.|
| bundleNames<sup>8+</sup> | Read only | Array\<string> | No | **bundleName** array in the running processes.|
## ApplicationStateObserver
......@@ -850,3 +891,44 @@ console.log('-------- processDiedInfo: ---------', processDiedInfo);
| [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. |
## ProcessRunningInformation
Defines the process running information.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Readable/Writable| Type | Mandatory| Description |
| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
| pid<sup>9+</sup> | Read only | number | No | Process ID. |
| 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.|
## ApplicationState<sup>9+</sup>
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Value | Description |
| -------------------- | --- | --------------------------------- |
| STATE_CREATE | 1 | State indicating that the application is being created. |
| STATE_FOREGROUND | 2 | State indicating that the application is running in the foreground. |
| STATE_ACTIVE | 3 | State indicating that the application is active. |
| STATE_BACKGROUND | 4 | State indicating that the application is running in the background. |
| STATE_DESTROY | 5 | State indicating that the application is destroyed. |
## ProcessState<sup>9+</sup>
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Value | Description |
| -------------------- | --- | --------------------------------- |
| STATE_CREATE | 1 | State indicating that the process is being created. |
| STATE_FOREGROUND | 2 | State indicating that the process is running in the foreground. |
| STATE_ACTIVE | 3 | State indicating that the process is active. |
| STATE_BACKGROUND | 4 | State indicating that the process is running in the background. |
| STATE_DESTROY | 5 | State indicating that the process is destroyed. |
......@@ -120,3 +120,14 @@ Enumerates the widget dimensions.
| Dimension_2_4<sup>9+</sup> | 3 | 2 x 4. |
| Dimension_4_4<sup>9+</sup> | 4 | 4 x 4. |
| Dimension_2_1<sup>9+</sup> | 5 | 2 x 1. |
## FormInfoFilter
Defines the widget information filter. Only the widget information that meets the filter is returned.
**System capability**: SystemCapability.Ability.Form
| Name | Yes | Description |
| ----------- | ---- | ------------ |
| moduleName<sup>9+</sup> | No | Module name.|
......@@ -183,7 +183,7 @@ Obtains the application's widget information that meets a filter criterion on th
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| filter | formInfo.FormInfoFilter | Yes| Filter criterion.|
| filter | [formInfo.FormInfoFilter](./js-apis-formInfo.md#forminfofilter) | Yes| Filter criterion.|
| callback | AsyncCallback&lt;Array&lt;[FormInfo](./js-apis-formInfo.md#forminfo-1)&gt;&gt; | Yes| Callback used to return the widget information.|
**Example**
......@@ -214,7 +214,7 @@ Obtains the application's widget information on the device. This API uses a prom
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| filter | formInfo.FormInfoFilter | No| Filter criterion.|
| filter | [formInfo.FormInfoFilter](./js-apis-formInfo.md) | No| Filter criterion.|
**Return value**
......
# ProcessRunningInfo
# ProcessRunningInfo<sup>(deprecated)</sup>
The **ProcessRunningInfo** module provides process running information.
> **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 provided by this module are deprecated since API version 9. You are advised to use [ProcessRunningInformation<sup>9+</sup>](js-apis-processrunninginformation.md) instead.
> - The initial APIs of this module are supported since API version 8.
## Usage
......@@ -19,9 +19,9 @@ appManager.getProcessRunningInfos((error,data) => {
## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
| Name| Type| Readable| Writable| Description|
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| pid | number | Yes| No| Process ID.|
| uid | number | Yes| No| User ID.|
......
# ProcessRunningInformation<sup>9+</sup>
The **ProcessRunningInformation** module provides process running information.
> **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.
## Usage Guidelines
The process running information is obtained through [appManager](js-apis-appmanager.md#appmanagergetprocessrunninginformation9).
```js
import appManager from '@ohos.application.appManager';
appManager.getProcessRunningInformation((error,data) => {
console.log("getProcessRunningInformation error: " + error.code + " data: " + JSON.stringify(data));
});
```
## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| pid | number | Yes| No| Process ID.|
| uid | number | Yes| No| User ID.|
| processName | string | Yes| No| Process name.|
| bundleNames | Array&lt;string&gt; | Yes| No| Names of all running bundles in the process.|
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册